]> granicus.if.org Git - python/commitdiff
Issue #20452: Oops, fix debug code :-/
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 31 Jan 2014 09:55:55 +0000 (10:55 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 31 Jan 2014 09:55:55 +0000 (10:55 +0100)
Add also event more debug info

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

index 4b3ecedd2293d7f5bbd0d3d2a6265eca9f942cd4..4b8e3feefe7198c49640458d411e8d166a44b1b7 100644 (file)
@@ -627,11 +627,16 @@ class BaseEventLoop(events.AbstractEventLoop):
             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 timeout is not None:
+                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__)
+            else:
+                if not event_list:
+                    print("WARNING: selector.select(timeout=%r) took dt=%.20f sec"
+                          % (timeout, dt), file=sys.__stdout__)
             if t1-t0 >= 1:
                 level = logging.INFO
             else:
index 4e02ee099568b574a6a48c4ffe602ae2832263a1..aef4993f2858ddf91f9b22aab81ea72e6a9bdab5 100644 (file)
@@ -1160,6 +1160,7 @@ class EventLoopTestsMixin:
         # FIXME: remove this imports, used for debug purpose (issue #20452)
         import time
         import platform
+        import os
 
         def _run_once():
             self.loop._run_once_counter += 1
@@ -1181,11 +1182,16 @@ class EventLoopTestsMixin:
 
         self.loop.run_until_complete(wait())
         calls.append(self.loop._run_once_counter)
+        try:
+            SC_CLK_TCK = os.sysconf('SC_CLK_TCK')
+        except Exception:
+            SC_CLK_TCK = None
         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'),
+                          SC_CLK_TCK,
                           platform.platform()))