![](/img/trans.png)
[英]What is the difference between Protocol and ProcessProtocol in Twisted python?
[英]Twisted ProcessProtocol read channel
當使用reactor.spawnProcess時,它如何附加到傳入的協議的讀取通道上? 即我可以傳遞SSHProcessProtocol並生成bash並發送ls
並獲得響應。 我知道它通過調用childDataReceived等來轉儲信息。但是它是怎么得到ls
呢? 我從這里看不到反應堆如何連接標准輸入http://twistedmatrix.com/documents/12.1.0/api/twisted.internet.interfaces.IProcessProtocol.html
這聽起來像是有關實現工作方式的問題。 接口顯然與實現無關。 他們描述了一個API,並將使該API實際工作的所有細節留給其他代碼。 因此,接口IProcessProtocol
的定義/文檔不會告訴您實現的工作原理。
IProcessProtocol
的傳輸大約有兩種實現,即IProcessTransport
。 傳輸負責在Twisted世界中實際執行I / O。 協議是解析和序列化邏輯所要去的地方,可為應用程序提供比拋出字節字符串更高級別的接口。
對於POSIX,一種實現是在twisted.internet.process
。 對於Windows,另一個在twisted.internet._dumbwin32proc
。 這些是您應該檢查其來源的模塊,以了解實現的工作原理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.