Skip to content

Conversation

@nolar
Copy link
Owner

@nolar nolar commented Jan 3, 2026

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 sync time.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.

@nolar nolar added the bug Something isn't working label Jan 3, 2026
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 sync `time.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.

Signed-off-by: Sergey Vasilyev <[email protected]>
@nolar nolar merged commit 7d54302 into main Jan 3, 2026
12 checks passed
@nolar nolar deleted the original-clock branch January 3, 2026 13:05
@coveralls
Copy link

coveralls commented Jan 3, 2026

Pull Request Test Coverage Report for Build 20677647547

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.9%) to 64.542%

Totals Coverage Status
Change from base Build 20671742169: 0.9%
Covered Lines: 294
Relevant Lines: 484

💛 - Coveralls

1 similar comment
@coveralls
Copy link

Pull Request Test Coverage Report for Build 20677647547

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.9%) to 64.542%

Totals Coverage Status
Change from base Build 20671742169: 0.9%
Covered Lines: 294
Relevant Lines: 484

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants