Skip to content
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
17 changes: 9 additions & 8 deletions lib/iris/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,14 @@ def _create_missing():
figure.savefig(hash_fname)
msg = 'Creating imagerepo entry: {} -> {}'
print(msg.format(unique_id, uri))
with open(repo_fname, 'wb') as fo:
json.dump(repo, codecs.getwriter('utf-8')(fo), indent=4,
sort_keys=True)
lock = filelock.FileLock(repo_fname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an improvement over the initial proposal.

# The imagerepo.json file is a critical resource, so ensure
# thread safe read/write behaviour via platform independent
# file locking.
with lock.acquire(timeout=600):
with open(repo_fname, 'wb') as fo:
json.dump(repo, codecs.getwriter('utf-8')(fo),
indent=4, sort_keys=True)

# TBD: Push this fix to imagehash (done!)
# See https://github.com/JohannesBuchner/imagehash/pull/31
Expand Down Expand Up @@ -804,11 +809,7 @@ def check_graphic(self):

"""
fname = os.path.join(_RESULT_PATH, 'imagerepo.lock')
lock = filelock.FileLock(fname)
# The imagerepo.json file is a critical resource, so ensure thread
# safe read/write behaviour via platform independent file locking.
with lock.acquire(timeout=600):
self._assert_graphic()
self._assert_graphic()

def _remove_testcase_patches(self):
"""Helper to remove per-testcase patches installed by :meth:`patch`."""
Expand Down