mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
#11866: Eliminate race condition in the computation of names for new threads.
Original patch by Peter Saveliev.
This commit is contained in:
parent
e1618491ad
commit
b186f1df41
2 changed files with 7 additions and 5 deletions
|
@ -9,7 +9,7 @@ except ImportError:
|
||||||
from time import time as _time
|
from time import time as _time
|
||||||
from traceback import format_exc as _format_exc
|
from traceback import format_exc as _format_exc
|
||||||
from _weakrefset import WeakSet
|
from _weakrefset import WeakSet
|
||||||
from itertools import islice as _islice
|
from itertools import islice as _islice, count as _count
|
||||||
try:
|
try:
|
||||||
from _collections import deque as _deque
|
from _collections import deque as _deque
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -726,11 +726,10 @@ class BrokenBarrierError(RuntimeError):
|
||||||
|
|
||||||
|
|
||||||
# Helper to generate new thread names
|
# Helper to generate new thread names
|
||||||
_counter = 0
|
_counter = _count().__next__
|
||||||
|
_counter() # Consume 0 so first non-main thread has id 1.
|
||||||
def _newname(template="Thread-%d"):
|
def _newname(template="Thread-%d"):
|
||||||
global _counter
|
return template % _counter()
|
||||||
_counter += 1
|
|
||||||
return template % _counter
|
|
||||||
|
|
||||||
# Active thread administration
|
# Active thread administration
|
||||||
_active_limbo_lock = _allocate_lock()
|
_active_limbo_lock = _allocate_lock()
|
||||||
|
|
|
@ -22,6 +22,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #11866: Eliminated race condition in the computation of names
|
||||||
|
for new threads.
|
||||||
|
|
||||||
- Issue #21905: Avoid RuntimeError in pickle.whichmodule() when sys.modules
|
- Issue #21905: Avoid RuntimeError in pickle.whichmodule() when sys.modules
|
||||||
is mutated while iterating. Patch by Olivier Grisel.
|
is mutated while iterating. Patch by Olivier Grisel.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue