Skip to content
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

Cannot destroy threadpool worker threads after fork #1631

Closed
jamadden opened this issue May 28, 2020 · 0 comments · Fixed by #1632
Closed

Cannot destroy threadpool worker threads after fork #1631

jamadden opened this issue May 28, 2020 · 0 comments · Fixed by #1632

Comments

@jamadden
Copy link
Member

  • gevent version: 20.5.1

If the threadpool worker ran a task that initialized a hub, because after the fork the thread is dead and we try to destroy from a different thread. This is a bit of a regression introduced by #1601

Traceback (most recent call last):
 File "//gunicorn-19.9.0-py2.7.egg/gunicorn/arbiter.py", line 203, in run
   self.manage_workers()
 File "//gunicorn-19.9.0-py2.7.egg/gunicorn/arbiter.py", line 545, in manage_workers
   self.spawn_workers()
 File "//gunicorn-19.9.0-py2.7.egg/gunicorn/arbiter.py", line 616, in spawn_workers
   self.spawn_worker()
 File "//gunicorn-19.9.0-py2.7.egg/gunicorn/arbiter.py", line 567, in spawn_worker
   pid = os.fork()
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/os.py", line 476, in fork
   return fork_and_watch(*args, **kwargs)
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/os.py", line 431, in fork_and_watch
   pid = fork()
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/os.py", line 198, in fork_gevent
   reinit()
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/hub.py", line 357, in reinit
   getattr(obj, '_on_fork', lambda: None)()
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/threadpool.py", line 384, in _on_fork
   worker.cleanup(worker._hub_of_worker)
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/threadpool.py", line 194, in cleanup
   hub_of_worker.destroy(True)
 File "//gevent-20.5.1-py2.7-linux-x86_64.egg/gevent/hub.py", line 787, in destroy
   self.throw(GreenletExit)
error: cannot switch to a different thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant