#11866: Eliminate race condition in the computation of names for new threads.
Original patch by Peter Saveliev.
This commit is contained in:
parent
429866d136
commit
d999c34955
|
@ -11,6 +11,7 @@ except ImportError:
|
|||
import warnings
|
||||
|
||||
from collections import deque as _deque
|
||||
from itertools import count as _count
|
||||
from time import time as _time, sleep as _sleep
|
||||
from traceback import format_exc as _format_exc
|
||||
|
||||
|
@ -623,11 +624,10 @@ class _Event(_Verbose):
|
|||
self.__cond.release()
|
||||
|
||||
# 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"):
|
||||
global _counter
|
||||
_counter = _counter + 1
|
||||
return template % _counter
|
||||
return template % _counter()
|
||||
|
||||
# Active thread administration
|
||||
_active_limbo_lock = _allocate_lock()
|
||||
|
|
Loading…
Reference in New Issue