diff options
Diffstat (limited to 'lib/sqlalchemy/util/langhelpers.py')
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 83f119660..8124764be 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -1179,11 +1179,8 @@ def counter(): # avoid the 2to3 "next" transformation... def _next(): - lock.acquire() - try: + with lock: return next(counter) - finally: - lock.release() return _next @@ -1362,14 +1359,11 @@ class symbol(object): _lock = compat.threading.Lock() def __new__(cls, name, doc=None, canonical=None): - cls._lock.acquire() - try: + with cls._lock: sym = cls.symbols.get(name) if sym is None: cls.symbols[name] = sym = _symbol(name, doc, canonical) return sym - finally: - symbol._lock.release() @classmethod def parse_user_argument( |
