sync scripts: Use asyncio.run instead of get_event_loop #14
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.
Replace the asyncio.get_event_loop() followed by run_until_complete(...) call with the asyncio.run(...), because it makes the code cleaner and works even if the event loop in the main thread has been cleared.
This fixes an issue with pytest-asyncio 0.25.2 which seems to clear the main thread event loop sometimes. The tests on sync_attachments and sync_objects used to fail if all tests were ran in the same pytest call, but if only those sync tests are selected (e.g. with
pytest -k test_sync
) then the tests used to pass. After this change they seem to pass on both cases.This might be the same issue as described in [1] (even if it is only for Python 3.9, but our issue happens with Python 3.12) or not.
[1] pytest-dev/pytest-asyncio#1039