简体   繁体   中英

Twisted ProcessProtocol read channel

When using reactor.spawnProcess how does this attach to the passed in protocol's read channel? ie I can passin a SSHProcessProtocol and spawn bash and send ls and get a response. I understand it dump the information via calling childDataReceived etc.. but how did it get ls ? I cant see from here how reactor is hooking up the stdin http://twistedmatrix.com/documents/12.1.0/api/twisted.internet.interfaces.IProcessProtocol.html

This sounds like a question about how the implementation works. Interfaces are explicitly not about implementations. They describe an API and leave all of the details of actually making that API work to other code. So the definition/documentation for IProcessProtocol , an interface, won't tell you anything about how the implementation works.

There happen to be roughly two implementations of the transport for IProcessProtocol , which is IProcessTransport . Transports are responsible for actually doing I/O in the Twisted world. Protocols are where parsing and serialization logic go, to provide applications with higher-level interfaces than throwing byte strings around.

One implementation, for POSIX, is in twisted.internet.process . The other, for Windows, is in twisted.internet._dumbwin32proc . These are the modules you should examine the source of in order to understand how the implementation works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM