Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145703: Fix asyncio.BaseEventLoop low clock resolution#145706

Open
CaptainFlint wants to merge 6 commits intopython:mainfrom
CaptainFlint:fix-issue-145703
Open

gh-145703: Fix asyncio.BaseEventLoop low clock resolution#145706
CaptainFlint wants to merge 6 commits intopython:mainfrom
CaptainFlint:fix-issue-145703

Conversation

@CaptainFlint
Copy link

@CaptainFlintCaptainFlint commentedMar 9, 2026
edited by bedevere-appbot
Loading

With this fix we make sure that even if the clock resolution becomes too small, the "next tick" will still be different from the current time, and the comparison remains valid.

Example: clock resolution = 1e-9, current uptime = 200 days (17280000 seconds). Floating point addition does not change the value, because the precision is too small. In this case the patch will usemath.ulp(), which is the smallest possible increment that will modify the current value.

Konstantin Vlasov added2 commitsMarch 9, 2026 19:52
asyncio event loop uses monotonic timer which in many systems is the OS uptime.With low enough clock resolution (often being 1e-09) and high enough uptime(~194 days), adding the "clock tick" to the current time hits the floatingpoint precision limits and does not change the time value.The comparison then returns invalid result, and tasks scheduled to trigger atthis exact moment are not triggered. They will be triggered only later, at thenext call.This commit fixes the issue by making sure the "next tick" is adjusted to thecurrent time's floating point precision. Therefore, end_time is guaranteed tobe incremented.
* Fixed sorting of imports* Fixed formatting in the NEWS entry* Reworded the explanatory comment
@picnixz
Copy link
Member

/home/runner/work/cpython/cpython/Doc/build/NEWS:40: WARNING: py:class reference target not found: asyncio.BaseEventLoop [ref.class]

Oh soBaseEventLoop doesn't have a documented entry. Maybe you can directly refer tocall_soon (https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_soon) ?

@CaptainFlint
Copy link
Author

Oh soBaseEventLoop doesn't have a documented entry. Maybe you can directly refer tocall_soon (https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_soon) ?

I found an existing reference tocall_soon in other NEWS entries and copied it. Looks like it worked.

@picnixz
Copy link
Member

If there are other methods that are affected by that, you can also mention them (I actually don't know if it's used by call_soon, I just assumed so because it's about callbacks)

@CaptainFlint
Copy link
Author

Well, the code that triggered the issue for me was usingcall_at. That implies thatcall_later is also affected, since they are basically the one.

I can't tell whethercall_soon is affected, actually, it's using a different approach, and I'm not familiar with the asyncio code structure to quickly see how the scheduler would process it.

I think, then, it's better to mention onlycall_at andcall_later as they are definitely affected.

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

I'm not an asyncio expert so I'll leave it for the maintainers but this looks like the best alternative.

CaptainFlint reacted with heart emoji
@CaptainFlint
Copy link
Author

Thanks a lot for your input and help! I really appreciate it!

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

Reviewers

@picnixzpicnixzpicnixz approved these changes

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303kumaraditya303 is a code owner

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@CaptainFlint@picnixz

[8]ページ先頭

©2009-2026 Movatter.jp