Skip to content

Commit 4716ceb

Browse files
committed
Reduced _vcs_cache_rlock contention in save_labscripts().
1 parent 903cc43 commit 4716ceb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

labscript/labscript.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,10 +2287,12 @@ def save_labscripts(hdf5_file):
22872287
continue
22882288
hdf5_file.create_dataset(save_path, data=open(path).read())
22892289
with _vcs_cache_rlock:
2290-
if path not in _vcs_cache:
2291-
# Add file to watch list and create its entry in the cache.
2292-
_file_watcher.add_file(path)
2293-
_file_watcher_callback(path, None, None)
2290+
already_cached = path in _vcs_cache
2291+
if not already_cached:
2292+
# Add file to watch list and create its entry in the cache.
2293+
_file_watcher.add_file(path)
2294+
_file_watcher_callback(path, None, None)
2295+
with _vcs_cache_rlock:
22942296
# Save the cached vcs output to the file.
22952297
for command, info, err in _vcs_cache[path]:
22962298
attribute_str = command[0] + ' ' + command[1]

0 commit comments

Comments
 (0)