-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
green.zmq program freeze with multiprocessing #1330
Comments
Could be related to this: gevent/gevent#1268 Possible solution: https://github.com/karellen/geventmp, but still very experimental at the time of writing |
Replacing 0MQ with Pipes works for both tests after all for this example (with from gevent import monkey
monkey.patch_all()
from multiprocessing import Process, Pipe
from threading import Thread
import sys
child_conn, parent_conn = Pipe()
def subprocess(pipe):
pipe.send("Hello from child proc client")
reply = pipe.recv()
print("Received reply: {}".format(reply))
def target(pipe):
while True:
msg = pipe.recv()
print("Received msg: {}".format(msg))
pipe.send("Hi from parent proc server")
if sys.argv[-1] == "1":
# start server subprocess
proc = Process(target=subprocess, args=(child_conn,))
proc.start()
thread = Thread(target=target, args=(parent_conn,))
thread.start()
else:
thread = Thread(target=target, args=(parent_conn,))
thread.start()
# start server subprocess
proc = Process(target=subprocess, args=(child_conn,))
proc.start() |
I'm seeing something similar in this issue with asyncio: #1333 |
I have a python application which spans multiple workers as sub processes (
multiprocessing.Process
).In order to communicate with my sub process workers I'm spanning a server thread in the main process which listenes to requests from the worker sub processes using pyzmq. The worker sub processes are being created at any point of time.
But using
gevent
andzmq.green
I encounter a freeze.I managed to trace down the problem with this minimal snippet:
When passing
1
as an argument in the end (python3 <script>.py 1
) it passes (spanning first the process and then the server thread seems to work). Butpython3 <script>.py
freezes the program execution.Sidenote: If removing the monkey-patching and changing
zmq.green
tozmq
it works tooTested with
Python 3.7.3
,gevent==1.4.0
andpyzmq==18.1.0
I'd appreciate any hints to solve the freeze while keeping
gevent
The text was updated successfully, but these errors were encountered: