多处理与扭曲
我的扭曲应用程序接收大量数据包并使用多个线程来处理数据包。我在单独的线程中处理数据包,以便反应堆循环可以自由地接收数据包。然而,由于 GIL,实际上只有 1 个线程在执行。结果,运行reactor循环的线程落后并丢失数据包。
我想使用多个进程而不是线程。有人可以指导我如何使用扭曲的多个进程吗?
My twisted application receives a large number of packet and uses multiple threads to process packets. I process packets in separate threads so that the reactor loop is free to receive packets. However, because of the GIL, only 1 thread is executing in reality. As a result, the thread in which reactor loop is running falls behind and loses packets.
Instead of threads I want to use multiple processes. Can someone please guide me how I can use multiple processes with twisted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
twisted.internet.reactor。
spawnProcess
或Ampoule
启动您的子流程。然后,您可以像接收网络数据包一样从这些进程接收标准输出。Use
twisted.internet.reactor.
spawnProcess
orAmpoule
to start your subprocesses. You can then receive standard output from those processes the same way you'd receive network packets.您可以使用透视代理“twisted.spread.pb”在多个twistd进程之间交换数据,甚至执行远程调用。
You can use perspective broker "twisted.spread.pb" to exchange date between your multiple twistd processes or even performing remote call.