summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-11 09:08:08 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-02-11 09:08:08 (GMT)
commit8425bf817f03949e0f77b9158a6b4d2d22157039 (patch)
tree890c90d1300bc4e9a6ec08b783fc3591f4e5f13d /Lib/asyncio
parent7b467db4d3f76600d14b39bacbe9bc4b1b10698e (diff)
downloadcpython-8425bf817f03949e0f77b9158a6b4d2d22157039.zip
cpython-8425bf817f03949e0f77b9158a6b4d2d22157039.tar.gz
cpython-8425bf817f03949e0f77b9158a6b4d2d22157039.tar.bz2
Issue #20505: Improve debug info in asyncio event loop
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 377ea21..e9cb934 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -634,12 +634,25 @@ class BaseEventLoop(events.AbstractEventLoop):
else:
logger.log(level, 'poll took %.3f seconds', t1-t0)
else:
- t0 = self.time()
+ t0_monotonic = time.monotonic()
+ t0 = time.perf_counter()
event_list = self._selector.select(timeout)
- dt = self.time() - t0
- if not event_list and timeout and dt < timeout:
- print("asyncio: selector.select(%.3f ms) took %.3f ms"
- % (timeout*1e3, dt*1e3),
+ dt = time.perf_counter() - t0
+ dt_monotonic = time.monotonic() - t0_monotonic
+ if not event_list and timeout: # and dt < timeout:
+ selector = self._selector.__class__.__name__
+ if (selector.startswith(("Poll", "Epoll", "Iocp"))
+ or timeout > 1e-3 or dt > 1e-3):
+ unit, factor = "ms", 1e3
+ else:
+ unit, factor = "us", 1e6
+ print("asyncio: %s.select(%.3f %s) took %.3f %s"
+ " (monotonic: %.3f %s, clock res: %.3f %s)"
+ % (self._selector.__class__.__name__,
+ timeout * factor, unit,
+ dt * factor, unit,
+ dt_monotonic * factor, unit,
+ self._clock_resolution * factor, unit),
file=sys.__stderr__, flush=True)
self._process_events(event_list)