Add patch to revert "bpo-1596321: Fix threading._shutdown() for
the main thread" https://bodhi.fedoraproject.org/updates/FEDORA-2021-e152ce5f31 https://github.com/GrahamDumpleton/mod_wsgi/issues/730
This commit is contained in:
parent
913221b8e2
commit
3216989552
@ -0,0 +1,103 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
|
||||
Date: Fri, 19 Nov 2021 13:37:16 +0100
|
||||
Subject: [PATCH] 00371: Revert "bpo-1596321: Fix threading._shutdown() for the
|
||||
main thread (GH-28549) (GH-28589)"
|
||||
|
||||
This reverts commit 94d19f606fa18a1c4d2faca1caf2f470a8ce6d46. It
|
||||
introduced regression causing FreeIPA's tests to fail.
|
||||
|
||||
For more info see:
|
||||
https://bodhi.fedoraproject.org/updates/FEDORA-2021-e152ce5f31
|
||||
https://github.com/GrahamDumpleton/mod_wsgi/issues/730
|
||||
---
|
||||
Lib/test/test_threading.py | 33 ---------------------------------
|
||||
Lib/threading.py | 25 ++++++++-----------------
|
||||
2 files changed, 8 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
|
||||
index af480b9014..a57085b75d 100644
|
||||
--- a/Lib/test/test_threading.py
|
||||
+++ b/Lib/test/test_threading.py
|
||||
@@ -814,39 +814,6 @@ class ThreadTests(BaseTestCase):
|
||||
threading.Thread(target=noop).start()
|
||||
# Thread.join() is not called
|
||||
|
||||
- def test_import_from_another_thread(self):
|
||||
- # bpo-1596321: If the threading module is first import from a thread
|
||||
- # different than the main thread, threading._shutdown() must handle
|
||||
- # this case without logging an error at Python exit.
|
||||
- code = textwrap.dedent('''
|
||||
- import _thread
|
||||
- import sys
|
||||
-
|
||||
- event = _thread.allocate_lock()
|
||||
- event.acquire()
|
||||
-
|
||||
- def import_threading():
|
||||
- import threading
|
||||
- event.release()
|
||||
-
|
||||
- if 'threading' in sys.modules:
|
||||
- raise Exception('threading is already imported')
|
||||
-
|
||||
- _thread.start_new_thread(import_threading, ())
|
||||
-
|
||||
- # wait until the threading module is imported
|
||||
- event.acquire()
|
||||
- event.release()
|
||||
-
|
||||
- if 'threading' not in sys.modules:
|
||||
- raise Exception('threading is not imported')
|
||||
-
|
||||
- # don't wait until the thread completes
|
||||
- ''')
|
||||
- rc, out, err = assert_python_ok("-c", code)
|
||||
- self.assertEqual(out, b'')
|
||||
- self.assertEqual(err, b'')
|
||||
-
|
||||
|
||||
class ThreadJoinOnShutdown(BaseTestCase):
|
||||
|
||||
diff --git a/Lib/threading.py b/Lib/threading.py
|
||||
index a3cb245ab9..ca1d6f08c4 100644
|
||||
--- a/Lib/threading.py
|
||||
+++ b/Lib/threading.py
|
||||
@@ -1433,29 +1433,20 @@ def _shutdown():
|
||||
|
||||
global _SHUTTING_DOWN
|
||||
_SHUTTING_DOWN = True
|
||||
+ # Main thread
|
||||
+ tlock = _main_thread._tstate_lock
|
||||
+ # The main thread isn't finished yet, so its thread state lock can't have
|
||||
+ # been released.
|
||||
+ assert tlock is not None
|
||||
+ assert tlock.locked()
|
||||
+ tlock.release()
|
||||
+ _main_thread._stop()
|
||||
|
||||
# Call registered threading atexit functions before threads are joined.
|
||||
# Order is reversed, similar to atexit.
|
||||
for atexit_call in reversed(_threading_atexits):
|
||||
atexit_call()
|
||||
|
||||
- # Main thread
|
||||
- if _main_thread.ident == get_ident():
|
||||
- tlock = _main_thread._tstate_lock
|
||||
- # The main thread isn't finished yet, so its thread state lock can't
|
||||
- # have been released.
|
||||
- assert tlock is not None
|
||||
- assert tlock.locked()
|
||||
- tlock.release()
|
||||
- _main_thread._stop()
|
||||
- else:
|
||||
- # bpo-1596321: _shutdown() must be called in the main thread.
|
||||
- # If the threading module was not imported by the main thread,
|
||||
- # _main_thread is the thread which imported the threading module.
|
||||
- # In this case, ignore _main_thread, similar behavior than for threads
|
||||
- # spawned by C libraries or using _thread.start_new_thread().
|
||||
- pass
|
||||
-
|
||||
# Join all non-deamon threads
|
||||
while True:
|
||||
with _shutdown_locks_lock:
|
@ -17,7 +17,7 @@ URL: https://www.python.org/
|
||||
#global prerel ...
|
||||
%global upstream_version %{general_version}%{?prerel}
|
||||
Version: %{general_version}%{?prerel:~%{prerel}}
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: Python
|
||||
|
||||
|
||||
@ -370,6 +370,17 @@ Patch328: 00328-pyc-timestamp-invalidation-mode.patch
|
||||
# a nightmare because it's basically a binary file.
|
||||
Patch353: 00353-architecture-names-upstream-downstream.patch
|
||||
|
||||
# 00371 # 1fc313929648e9b543542de09f59c55e175ac45a
|
||||
# Revert "bpo-1596321: Fix threading._shutdown() for the main thread (GH-28549) (GH-28589)"
|
||||
#
|
||||
# This reverts commit 94d19f606fa18a1c4d2faca1caf2f470a8ce6d46. It
|
||||
# introduced regression causing FreeIPA's tests to fail.
|
||||
#
|
||||
# For more info see:
|
||||
# https://bodhi.fedoraproject.org/updates/FEDORA-2021-e152ce5f31
|
||||
# https://github.com/GrahamDumpleton/mod_wsgi/issues/730
|
||||
Patch371: 00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-gh-28549-gh-28589.patch
|
||||
|
||||
# (New patches go here ^^^)
|
||||
#
|
||||
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
||||
@ -1783,6 +1794,9 @@ CheckPython optimized
|
||||
# ======================================================
|
||||
|
||||
%changelog
|
||||
* Fri Nov 19 2021 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.9.9-2
|
||||
- Add patch to revert "bpo-1596321: Fix threading._shutdown() for the main thread"
|
||||
|
||||
* Tue Nov 16 2021 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.9.9-1
|
||||
- Update to 3.9.9
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user