Use the original clock if not enabled #23
Merged
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.
We now patch the event loop at creation — even if time compaction is not enabled. This is indeed required as we cannot patch the higher-scoped event loop later when the lower-scoped tests require it based on their individual options.
However, this replaces the
loop.time()function with our fake time, which starts at zero — even when the event loop is supposed to be "normal".Revert the behaviour of "normal" event loops to their original clock.
This was originally caused and detected in a very rare case:
test_nonthreadsafe_indeed_fails()шт Kopf, strictly in PyPy 3.11 (both setups) — but not шт PyPy 3.10, and not in any CPython. Specifically, the loop chronometer was showing the loop time advances for 0.4998 seconds despite there was a synctime.sleep(0.5)before any async activity happens. Since it is unlikely that there were any hidden or premature activities in the event loop, it was likely the issue with the time measurement of the replaced clock of the forcedly disactivated (but patched) event loop.