mirror of
https://github.com/python/cpython
synced 2024-10-17 06:18:40 +00:00
_once(): Removed obfuscating aliasing of _once_lock.
This commit is contained in:
parent
fd0f0c9f02
commit
1749b252c9
|
@ -98,19 +98,17 @@ def _once(var, initializer):
|
|||
"""
|
||||
|
||||
vars = globals()
|
||||
lock = _once_lock
|
||||
|
||||
# Check first outside the lock.
|
||||
if vars.get(var) is not None:
|
||||
return
|
||||
try:
|
||||
lock.acquire()
|
||||
_once_lock.acquire()
|
||||
# Check again inside the lock.
|
||||
if vars.get(var) is not None:
|
||||
return
|
||||
vars[var] = initializer()
|
||||
finally:
|
||||
lock.release()
|
||||
_once_lock.release()
|
||||
|
||||
class _RandomNameSequence:
|
||||
"""An instance of _RandomNameSequence generates an endless
|
||||
|
|
Loading…
Reference in a new issue