Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Romain Dorgueil
2019-05-16 15:11:19 +02:00

View File

@ -146,12 +146,14 @@ class Exclusive(ContextDecorator):
""" """
_locks = {} _locks = {}
_locks_creation_lock = threading.Lock()
def __init__(self, wrapped): def __init__(self, wrapped):
self._wrapped = wrapped self._wrapped = wrapped
def get_lock(self): def get_lock(self):
_id = id(self._wrapped) _id = id(self._wrapped)
with Exclusive._locks_creation_lock:
if not _id in Exclusive._locks: if not _id in Exclusive._locks:
Exclusive._locks[_id] = threading.RLock() Exclusive._locks[_id] = threading.RLock()
return Exclusive._locks[_id] return Exclusive._locks[_id]