[Python-checkins] cpython (3.4): Issue #20505: Improve debug info in asyncio event loop

larry.hastings python-checkins at python.org
Mon Mar 17 07:31:22 CET 2014


http://hg.python.org/cpython/rev/e44ff3b7a497
changeset:   89697:e44ff3b7a497
branch:      3.4
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Feb 11 10:08:08 2014 +0100
summary:
  Issue #20505: Improve debug info in asyncio event loop

files:
  Lib/asyncio/base_events.py |  23 ++++++++++++++++++-----
  1 files changed, 18 insertions(+), 5 deletions(-)


diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -634,12 +634,25 @@
             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)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list