You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
subprocess.Popen gets stuck inside the fork hook if gevent.threadpool is used. The weird thing is if the print(gevent.threadpool) line is removed, issue does not happen.
Reproducer
import gevent.monkey
gevent.monkey.patch_all(
subprocess=True,
)
import os, gevent, subprocess, time
def hook():
print("inside fork hook")
gevent.get_hub().threadpool.apply(lambda: print("run with threadpool!"))
os.register_at_fork(after_in_child=hook)
print(gevent.get_hub().threadpool, " >>> HUB.threadpool before hook") # --> if you remove this line, this works!!
r = subprocess.Popen("pwd", close_fds=False)
time.sleep(1.0)
print("ended!", r)
Issue only happens when the print(gevent.get_hub().threadpool, " >>> HUB.threadpool before hook") is there. Somehow, reading threadpool before the fork hook causes the problem.
Issue happens both on Linux and MacOsx.
Issue only happens with Python 3.11 and above. 3.10 works just fine.
The text was updated successfully, but these errors were encountered:
sumerc
changed the title
gevent stuck when gevent.threadpool is used inside a fork hookgeventsubprocess.POpen gets stuck when gevent.threadpool is used inside a fork hook
Feb 20, 2024
sumerc
changed the title
geventsubprocess.POpen gets stuck when gevent.threadpool is used inside a fork hookgevent gets stuck when gevent.threadpool is used inside a fork hook
Feb 20, 2024
Description
subprocess.Popen
gets stuck inside the fork hook ifgevent.threadpool
is used. The weird thing is if theprint(gevent.threadpool)
line is removed, issue does not happen.Reproducer
print(gevent.get_hub().threadpool, " >>> HUB.threadpool before hook")
is there. Somehow, reading threadpool before the fork hook causes the problem.3.10
works just fine.The text was updated successfully, but these errors were encountered: