summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/threading.py')
-rw-r--r--Lib/threading.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 0edfaf8..41c3a9f 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -1593,8 +1593,11 @@ def _shutdown():
# 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()
+ if tlock.locked():
+ # It should have been released already by
+ # _PyInterpreterState_SetNotRunningMain(), but there may be
+ # embedders that aren't calling that yet.
+ tlock.release()
_main_thread._stop()
else:
# bpo-1596321: _shutdown() must be called in the main thread.