]> granicus.if.org Git - python/commitdiff
Issue #20452: add more info in case of test_asyncio failure to try to debug the
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 31 Jan 2014 08:29:35 +0000 (09:29 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 31 Jan 2014 08:29:35 +0000 (09:29 +0100)
failure on buildbot "x86 Ubuntu Shared 3.x"

Lib/asyncio/base_events.py
Lib/test/test_asyncio/test_events.py

index 58c3520ea3c93e3084be65f6b01c6005c321c135..4b3ecedd2293d7f5bbd0d3d2a6265eca9f942cd4 100644 (file)
@@ -620,10 +620,18 @@ class BaseEventLoop(events.AbstractEventLoop):
                 timeout = min(timeout, deadline)
 
         # TODO: Instrumentation only in debug mode?
-        if logger.isEnabledFor(logging.INFO):
+        # FIXME: don't force log (issue #20452)
+        if True: #logger.isEnabledFor(logging.INFO):
             t0 = self.time()
             event_list = self._selector.select(timeout)
             t1 = self.time()
+            # FIXME: remove these debug info (issue #20452)
+            dt = t1-t0
+            if dt < timeout and not event_list:
+                print("WARNING: selector.select(timeout=%.20f) took dt=%.20f sec (dt-timeout=%+.20f)"
+                      % (timeout, dt, dt-timeout), file=sys.__stdout__)
+                print("WARNING: dt+%.20f > timeout? %s"
+                      % (self._granularity, (dt + self._granularity) > timeout), file=sys.__stdout__)
             if t1-t0 >= 1:
                 level = logging.INFO
             else:
index 24808cb11c773b10d5df3021b7a6450c97e64c2e..4e02ee099568b574a6a48c4ffe602ae2832263a1 100644 (file)
@@ -1157,6 +1157,10 @@ class EventLoopTestsMixin:
         w.close()
 
     def test_timeout_rounding(self):
+        # FIXME: remove this imports, used for debug purpose (issue #20452)
+        import time
+        import platform
+
         def _run_once():
             self.loop._run_once_counter += 1
             orig_run_once()
@@ -1177,7 +1181,12 @@ class EventLoopTestsMixin:
 
         self.loop.run_until_complete(wait())
         calls.append(self.loop._run_once_counter)
-        self.assertEqual(calls, [1, 3, 5, 6])
+        self.assertEqual(calls, [1, 3, 5, 6],
+                         # FIXME: remove these info, used for debug purpose (issue #20452)
+                         (self.loop._granularity,
+                          self.loop._selector.resolution,
+                          time.get_clock_info('monotonic'),
+                          platform.platform()))
 
 
 class SubprocessTestsMixin: