Catch KeyError as another possible failure of multithreading #710
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When multithreading support is disabled, it is possible for operations on synced dicts to fail with a KeyError (as well as the other errors that were already being caught), so the multithreading test now catches that failure. Note that this is a bug in the test only, not in signac itself.
Motivation and Context
PyPy3 tests of multithreading have been failing due to this omission (see #705 and #706). Additionally, once this failure occurs, the buffer is in an invalid state, so future multithreading tests can fail in unpredictable ways. I reproduced the issue by running
test_json_buffered_collection.py::TestBufferedJSONDictWriteConcern::test_multithreaded
using pytest-repeat to run the test 100 times. I invariably observed failures within this number of tests. I then verified that catching the KeyError and clearing the collection prevents the error by running the test a few times with 1000 repeats (with pytest-xdist just to make sure that #705 was safe). I observed no further errors.Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist:
If necessary: