summaryrefslogtreecommitdiffstats
path: root/Lib/concurrent/futures/thread.py
diff options
context:
space:
mode:
authorAndrei Bodrov <Drino@users.noreply.github.com>2024-11-22 16:20:34 (GMT)
committerGitHub <noreply@github.com>2024-11-22 16:20:34 (GMT)
commit1848ce61f349533ae5892a8c24c2e0e3c364fc8a (patch)
tree47491803ee64856ca9c662d0d8f306eade05c0dd /Lib/concurrent/futures/thread.py
parent7725c0371a93be3ccfaff4871014a80bdf0ea274 (diff)
downloadcpython-1848ce61f349533ae5892a8c24c2e0e3c364fc8a.zip
cpython-1848ce61f349533ae5892a8c24c2e0e3c364fc8a.tar.gz
cpython-1848ce61f349533ae5892a8c24c2e0e3c364fc8a.tar.bz2
gh-88110: Clear concurrent.futures.thread._threads_queues after fork to avoid joining parent process' threads (GH-126098)
Threads are gone after fork, so clear the queues too. Otherwise the child process (here created via multiprocessing.Process) crashes on interpreter exit. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/concurrent/futures/thread.py')
-rw-r--r--Lib/concurrent/futures/thread.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py
index 16cc553..909359b 100644
--- a/Lib/concurrent/futures/thread.py
+++ b/Lib/concurrent/futures/thread.py
@@ -41,6 +41,7 @@ if hasattr(os, 'register_at_fork'):
os.register_at_fork(before=_global_shutdown_lock.acquire,
after_in_child=_global_shutdown_lock._at_fork_reinit,
after_in_parent=_global_shutdown_lock.release)
+ os.register_at_fork(after_in_child=_threads_queues.clear)
class WorkerContext: