File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 from time import time as _time
1010from traceback import format_exc as _format_exc
1111from _weakrefset import WeakSet
12- from itertools import islice as _islice
12+ from itertools import islice as _islice , count as _count
1313try :
1414 from _collections import deque as _deque
1515except ImportError :
@@ -726,11 +726,10 @@ class BrokenBarrierError(RuntimeError):
726726
727727
728728# Helper to generate new thread names
729- _counter = 0
729+ _counter = _count ().__next__
730+ _counter () # Consume 0 so first non-main thread has id 1.
730731def _newname (template = "Thread-%d" ):
731- global _counter
732- _counter += 1
733- return template % _counter
732+ return template % _counter ()
734733
735734# Active thread administration
736735_active_limbo_lock = _allocate_lock ()
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ Core and Builtins
2222Library
2323-------
2424
25+ - Issue #11866: Eliminated race condition in the computation of names
26+ for new threads.
27+
2528- Issue #21905: Avoid RuntimeError in pickle.whichmodule() when sys.modules
2629 is mutated while iterating. Patch by Olivier Grisel.
2730
You can’t perform that action at this time.
0 commit comments