Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid deadlock in SyncedCollection #530

Merged
merged 1 commit into from
Mar 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion signac/synced_collections/data_types/synced_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def __init__(self, parent=None, *args, **kwargs):
self._load_and_save = self._LoadSaveType(self)

if self._supports_threading:
self._locks[self._lock_id] = RLock()
with self._cls_lock:
if self._lock_id not in self._locks:
self._locks[self._lock_id] = RLock()

@classmethod
def _register_validators(cls):
Expand Down Expand Up @@ -235,6 +237,7 @@ def __init_subclass__(cls):

# Monkey-patch subclasses that support locking.
if cls._supports_threading:
cls._cls_lock = RLock()
cls._locks = {}
cls.enable_multithreading()
else:
Expand Down