Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-88110: clear concurrent.futures.thread._threads_queues after fork #101940

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

Closed
wants to merge 3 commits into from

Conversation

marmarek
Copy link
Contributor

@marmarek marmarek commented Feb 15, 2023

Threads are gone after fork, so clear the queues too. Otherwise the child process (here created via multiprocessing.Process) crashes on interpreter exit with:

Traceback (most recent call last):
  File "/usr/lib64/python3.11/multiprocessing/popen_fork.py", line 72, in _launch
    code = process_obj._bootstrap(parent_sentinel=child_r)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/multiprocessing/process.py", line 332, in _bootstrap
    threading._shutdown()
  File "/usr/lib64/python3.11/threading.py", line 1561, in _shutdown
    atexit_call()
  File "/usr/lib64/python3.11/concurrent/futures/thread.py", line 31, in _python_exit
    t.join()
  File "/usr/lib64/python3.11/threading.py", line 1109, in join
    raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread

… fork

Threads are gone after fork, so clear the queues too. Otherwise the
child process (here created via multiprocessing.Process) crashes on
interpreter exit with:

    Traceback (most recent call last):
      File "/usr/lib64/python3.11/multiprocessing/popen_fork.py", line 72, in _launch
        code = process_obj._bootstrap(parent_sentinel=child_r)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/multiprocessing/process.py", line 332, in _bootstrap
        threading._shutdown()
      File "/usr/lib64/python3.11/threading.py", line 1561, in _shutdown
        atexit_call()
      File "/usr/lib64/python3.11/concurrent/futures/thread.py", line 31, in _python_exit
        t.join()
      File "/usr/lib64/python3.11/threading.py", line 1109, in join
        raise RuntimeError("cannot join current thread")
    RuntimeError: cannot join current thread

Fixes python#88110
@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@arhadthedev arhadthedev added stdlib Python modules in the Lib dir topic-multiprocessing labels Feb 16, 2023
@serhiy-storchaka
Copy link
Member

Could you please add tests @marmarek?

@gpshead
Copy link
Member

gpshead commented Nov 20, 2024

closing in favor of #126098 which built upon this.

@gpshead gpshead closed this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

6 participants