From 163b1e32f24cefb4fe6663244404c5e60716245a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 27 Mar 2020 18:01:47 +0100 Subject: [PATCH] bpo-40091: Fix a crash in logging after fork Fix a crash in the logging module after fork in the process process: reset the main logging lock. --- Lib/logging/__init__.py | 2 +- .../next/Library/2020-03-27-18-03-12.bpo-40091.ZIh4oL.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2020-03-27-18-03-12.bpo-40091.ZIh4oL.rst diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 59d5fa5b64d2232..9ea2a19667cb9bb 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -257,8 +257,8 @@ def _after_at_fork_child_reinit_locks(): # Similar to what PyErr_WriteUnraisable does. print("Ignoring exception from logging atfork", instance, "._reinit_lock() method:", err, file=sys.stderr) - _releaseLock() # Acquired by os.register_at_fork(before=. + _lock = threading.RLock() os.register_at_fork(before=_acquireLock, after_in_child=_after_at_fork_child_reinit_locks, diff --git a/Misc/NEWS.d/next/Library/2020-03-27-18-03-12.bpo-40091.ZIh4oL.rst b/Misc/NEWS.d/next/Library/2020-03-27-18-03-12.bpo-40091.ZIh4oL.rst new file mode 100644 index 000000000000000..2177e6e9c3fadf2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-03-27-18-03-12.bpo-40091.ZIh4oL.rst @@ -0,0 +1,2 @@ +Fix a crash in the :mod:`logging` module after fork in the process process: +reset the main logging lock.