[英]Queue between Python processes without using the multiprocessing module
I need to start a child process that doesn't share its parent process's Python interpreter (Jython and CPython). 我需要启动一个不共享其父进程的Python解释器(Jython和CPython)的子进程。 I would like to use a convenient IPC tool like
Queue.Queue
or multiprocessing.Connection
. 我想使用便捷的IPC工具,例如
Queue.Queue
或multiprocessing.Connection
。
How can that be achieved? 如何实现?
You could use a message queue library like ZeroMQ . 您可以使用消息队列库,例如ZeroMQ 。 It has language bindings for Python and Java, your Jython scripts would need to use the Java classes of these bindings.
它具有用于Python和Java的语言绑定,您的Jython脚本将需要使用这些绑定的Java类。 Alternatively, there's a pure Python message queue snakeMQ .
另外,还有一个纯Python消息队列snakeMQ 。 This should run in both C-Python and Jython as it does not require native libraries.
这应该在C-Python和Jython中运行,因为它不需要本机库。 You could encode your messages if it is more than strings and numbers, using JSON, or pickle (I'm not sure if pickle output is compatible between C-Python and Jython, though).
如果消息不只是字符串和数字,则可以使用JSON或pickle进行编码(我不知道pickle的输出是否在C-Python和Jython之间兼容)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.