diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2024-05-03 11:45:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-03 11:45:46 -0700 |
commit | 998c3856c1e922ece806c162858dc587a1e92e02 (patch) | |
tree | 03077e946db80e7e78df5a9c3e14e6ba5ca04bcf /Lib/multiprocessing/forkserver.py | |
parent | cb57a52a85a7845b1c017085f05a7f6d71855edc (diff) | |
download | cpython-998c3856c1e922ece806c162858dc587a1e92e02.tar.gz cpython-998c3856c1e922ece806c162858dc587a1e92e02.zip |
gh-83856: Honor atexit for all multiprocessing start methods (GH-114279)
Use atexit for all multiprocessing start methods to cleanup.
See the GH-114279 PR discussion and related issue for details as to why.
Diffstat (limited to 'Lib/multiprocessing/forkserver.py')
-rw-r--r-- | Lib/multiprocessing/forkserver.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/multiprocessing/forkserver.py b/Lib/multiprocessing/forkserver.py index 4642707dae2..53b8c492675 100644 --- a/Lib/multiprocessing/forkserver.py +++ b/Lib/multiprocessing/forkserver.py @@ -1,3 +1,4 @@ +import atexit import errno import os import selectors @@ -271,6 +272,8 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None): selector.close() unused_fds = [alive_r, child_w, sig_r, sig_w] unused_fds.extend(pid_to_fd.values()) + atexit._clear() + atexit.register(util._exit_function) code = _serve_one(child_r, fds, unused_fds, old_handlers) @@ -278,6 +281,7 @@ def main(listener_fd, alive_r, preload, main_path=None, sys_path=None): sys.excepthook(*sys.exc_info()) sys.stderr.flush() finally: + atexit._run_exitfuncs() os._exit(code) else: # Send pid to client process |