【问题标题】:What is the difference between Protocol and ProcessProtocol in Twisted python?Twisted python中的Protocol和ProcessProtocol有什么区别?
【发布时间】:2015-08-10 21:23:23
【问题描述】:

我希望编写一个可以通过多个套接字连接到服务器的 Twisted 客户端应用程序。我希望使用工厂、协议、传输模型,因为它们似乎提供了一个很好的框架。 interfaces、Protocol 和 ProcessProtocol 都继承自 BaseProtocol,但它们有何不同? ProcessProtocol 是协议池吗?特别是ProcessProtocol中的子进程是什么,能不能把它当成socket对象呢?

IProtocol(Interface): 
dataReceived(data)
connectionLost(reason)
makeConnection(transport) 
connectionMade()

IProcessProtocol(Interface): 

childDataReceived(childFD, data)
childConnectionLost(childFD)
processExited(reason)
processEnded(reason)

编辑:发现 ProcessProtocol 实际上可能正在启动 python 进程。

【问题讨论】:

    标签: python sockets twisted twisted.web


    【解决方案1】:

    ProcessProtocol 是用于communicate with a sub-process 的协议。该进程可以是 Python 进程,也可以是您希望通过其标准输入、标准输出和标准错误流启动并与之通信的任何其他程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      相关资源
      最近更新 更多