_once(): Removed obfuscating aliasing of _once_lock.

This commit is contained in:
Tim Peters 2002-08-13 23:31:02 +00:00
parent fd0f0c9f02
commit 1749b252c9
1 changed files with 2 additions and 4 deletions

View File

@ -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