From 93b7268111aa069c7e8c74cb75384ab5ecb11a40 Mon Sep 17 00:00:00 2001 From: "yizhou.xu" Date: Mon, 25 Nov 2024 03:55:51 -0500 Subject: [PATCH 1/2] Replace os._exit() to sys.exit(), so that .so will alos be unloaded in child process --- Lib/multiprocessing/popen_fork.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/multiprocessing/popen_fork.py b/Lib/multiprocessing/popen_fork.py index 625981cf47627c..2c0c9f01b6c867 100644 --- a/Lib/multiprocessing/popen_fork.py +++ b/Lib/multiprocessing/popen_fork.py @@ -1,5 +1,6 @@ import os import signal +import sys from . import util @@ -70,7 +71,7 @@ def _launch(self, process_obj): os.close(parent_w) code = process_obj._bootstrap(parent_sentinel=child_r) finally: - os._exit(code) + sys.exit(code) else: os.close(child_w) os.close(child_r) From 605e96122f31d181d674d42c963b0ba2d80ea335 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 09:55:05 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/multiprocessing/process.py | 3 ++- .../Library/2024-11-25-09-55-04.gh-issue-127213.d2pVyU.rst | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2024-11-25-09-55-04.gh-issue-127213.d2pVyU.rst diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py index 271ba3fd325138..cadbfa4508bab0 100644 --- a/Lib/multiprocessing/process.py +++ b/Lib/multiprocessing/process.py @@ -130,7 +130,8 @@ def terminate(self): Terminate process; sends SIGTERM signal or uses TerminateProcess() ''' self._check_closed() - self._popen.terminate() + if self._popen is not None: + self._popen.terminate() def kill(self): ''' diff --git a/Misc/NEWS.d/next/Library/2024-11-25-09-55-04.gh-issue-127213.d2pVyU.rst b/Misc/NEWS.d/next/Library/2024-11-25-09-55-04.gh-issue-127213.d2pVyU.rst new file mode 100644 index 00000000000000..2ef99210d23bbf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-11-25-09-55-04.gh-issue-127213.d2pVyU.rst @@ -0,0 +1 @@ +Replace os._exit() to sys.exit(), so that .so will alos be unloaded in child process