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

Fix bug with property_importer when executed in parallel seeing database locks #257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions tangos/tools/property_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ def _import_properties_for_timestep(self, ts, property_names, object_typetag):
self._object_cache = timestep_object_cache.TimestepObjectCache(ts)
self._session = core.Session.object_session(ts)

property_db_names = [core.dictionary.get_or_create_dictionary_item(self._session, name) for name in
property_names]
with parallel_tasks.ExclusiveLock("add_properties"):
# if a dictionary item may be created, we need the database locked. But note this may be highly inefficent.
# Leaving it for now since this whole property_importer step isn't a rate limiting factor in any known workflow
property_db_names = [core.dictionary.get_or_create_dictionary_item(self._session, name) for name in
property_names]
self._session.commit()

rows_to_store = []
for values in self.handler.iterate_object_properties_for_timestep(ts.extension, object_typetag, property_names):
if len(values)!=2+len(property_db_names):
Expand Down
Loading