Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1db2ba3

Browse files
committed
Issue #20505: use also the monotonic time to decide if asyncio debug traces
should be printed
1 parent 5d1ea04 commit 1db2ba3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/asyncio/base_events.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,16 @@ def _run_once(self):
639639
event_list = self._selector.select(timeout)
640640
dt = time.perf_counter() - t0
641641
dt_monotonic = time.monotonic() - t0_monotonic
642-
if not event_list and timeout and dt < timeout:
642+
if (not event_list and timeout
643+
and (dt < timeout or dt_monotonic < timeout)):
643644
selector = self._selector.__class__.__name__
644645
if (selector.startswith(("Poll", "Epoll", "Iocp"))
645646
or timeout > 1e-3 or dt > 1e-3):
646647
unit, factor = "ms", 1e3
647648
else:
648649
unit, factor = "us", 1e6
649-
print("asyncio: %s.select(%.3f %s) took %.3f %s"
650-
" (monotonic: %.3f %s, clock res: %.3f %s)"
650+
print("asyncio: %s.select(%.4f %s) took %.3f %s"
651+
" (monotonic=%.3f %s, clock res=%.3f %s)"
651652
% (self._selector.__class__.__name__,
652653
timeout * factor, unit,
653654
dt * factor, unit,

0 commit comments

Comments
 (0)