[英]processing HTTPS requests and ZeroMQ messages in parallel inside Twisted
I am trying to do two things in parallel: 我正在尝试同时做两件事:
NOT_DONE_YET
) NOT_DONE_YET
) I know how to make each of these two things separately, but how can I do them in parallel? 我知道如何分别制作这两件事,但是如何并行进行呢? To be specific, how can I receive messages from ZeroMQ inside the Twisted framework, when I am already listening to TCP sockets?
具体来说,当我已经在侦听TCP套接字时,如何从Twisted框架内的ZeroMQ接收消息?
You can get support for ZMQ here, in txZMQ . 您可以在txZMQ中获得对ZMQ的支持。
It sounds like you already know how to deal with the HTTP request. 听起来您已经知道如何处理HTTP请求。
To do these things in parallel, just create your ZmqSubConnection
and your twisted.web.server.Site
, with references to each other as necessary for your application. 要并行执行这些操作,只需创建
ZmqSubConnection
和twisted.web.server.Site
,并在应用程序中根据需要相互引用即可。 No special set-up is required. 无需特殊设置。
Just make sure you only create and run one reactor. 只要确保只创建并运行一个反应堆即可。 Other people with similar questions sometimes don't understand that
reactor.run()
means "run the event loop for the whole process", and not "run this one thing I set up". 遇到类似问题的其他人有时不理解“
reactor.run()
意思是“运行整个过程的事件循环”,而不是“运行我设置的这一件事”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.