https://github.com/python/cpython/commit/77c06f3da629b5088975309959ef6895bef841e3
commit: 77c06f3da629b5088975309959ef6895bef841e3
branch: main
author: Konstantin Vlasov <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-03-14T11:07:30+05:30
summary:

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

files:
A Misc/NEWS.d/next/Library/2026-03-09-19-59-05.gh-issue-145703.4EEP7J.rst
M Lib/asyncio/base_events.py

diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index b565b1d8a9e226..0930ef403c6c4b 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -19,14 +19,15 @@
 import errno
 import heapq
 import itertools
+import math
 import os
 import socket
 import stat
 import subprocess
+import sys
 import threading
 import time
 import traceback
-import sys
 import warnings
 import weakref
 
@@ -2022,7 +2023,10 @@ def _run_once(self):
         event_list = None
 
         # Handle 'later' callbacks that are ready.
-        end_time = self.time() + self._clock_resolution
+        now = self.time()
+        # Ensure that `end_time` is strictly increasing
+        # when the clock resolution is too small.
+        end_time = now + max(self._clock_resolution, math.ulp(now))
         while self._scheduled:
             handle = self._scheduled[0]
             if handle._when >= end_time:
diff --git 
a/Misc/NEWS.d/next/Library/2026-03-09-19-59-05.gh-issue-145703.4EEP7J.rst 
b/Misc/NEWS.d/next/Library/2026-03-09-19-59-05.gh-issue-145703.4EEP7J.rst
new file mode 100644
index 00000000000000..bc239ce58c9eed
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-03-09-19-59-05.gh-issue-145703.4EEP7J.rst
@@ -0,0 +1,3 @@
+:mod:`asyncio`: Make sure that :meth:`loop.call_at <asyncio.loop.call_at>` and
+:meth:`loop.call_later <asyncio.loop.call_later>` trigger scheduled events on
+time when the clock resolution becomes too small.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to