[Python-checkins] bpo-44422: threading.Thread reuses the _delete() method (GH-26741)

vstinner webhook-mailer at python.org
Wed Jun 16 05:41:39 EDT 2021


https://github.com/python/cpython/commit/0729694246174a5c2f0ae197f2e0dbea61b90c9f
commit: 0729694246174a5c2f0ae197f2e0dbea61b90c9f
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2021-06-16T11:41:17+02:00
summary:

bpo-44422: threading.Thread reuses the _delete() method (GH-26741)

The _bootstrap_inner() method of threading.Thread now reuses its
_delete() method rather than accessing _active() directly. It became
possible since _active_limbo_lock became reentrant. Moreover, it no
longer ignores any exception when deleting the thread from the
_active dictionary.

files:
M Lib/threading.py

diff --git a/Lib/threading.py b/Lib/threading.py
index 766011fa0312b..c2b94a5045514 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -1010,13 +1010,7 @@ def _bootstrap_inner(self):
             except:
                 self._invoke_excepthook(self)
         finally:
-            with _active_limbo_lock:
-                try:
-                    # We don't call self._delete() because it also
-                    # grabs _active_limbo_lock.
-                    del _active[get_ident()]
-                except:
-                    pass
+            self._delete()
 
     def _stop(self):
         # After calling ._stop(), .is_alive() returns False and .join() returns



More information about the Python-checkins mailing list