Skip to content

Commit

Permalink
Merge pull request #243 from wpfff/fix/dontflushwithoutswmr
Browse files Browse the repository at this point in the history
bugfix: prevent flushing when we are updating data.
  • Loading branch information
wpfff committed Dec 15, 2021
2 parents 341e2fb + 4626dc2 commit 42f2a84
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plottr/data/datadict_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ def write_data_to_file(datadict: DataDict,
raise RuntimeError('Group does not exist, initialize file first.')
grp = f[groupname]

# TODO: this should become a more robust solution.
# should prevent writing anything in non-swmr mode when there's danger
# that another process is reading.
# also should detect if we can currently write anything.
# if we want to use swmr, we need to make sure that we're not
# creating any more objects (see hdf5 docs).
allexist = True
Expand All @@ -208,7 +212,6 @@ def write_data_to_file(datadict: DataDict,
for k, v in datadict.meta_items(clean_keys=False):
set_attr(grp, k, v)

f.flush()
if allexist and swmr_mode and not f.swmr_mode:
f.swmr_mode = True

Expand Down

0 comments on commit 42f2a84

Please sign in to comment.