]> granicus.if.org Git - python/commitdiff
asyncio: Cleanup logging in BaseEventLoop._run_once()
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 22 Jan 2014 11:26:01 +0000 (12:26 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 22 Jan 2014 11:26:01 +0000 (12:26 +0100)
logger.log() is now responsible to format the timeout. It might be faster if
the log is disabled for DEBUG level, but it's also more readable and fix
an issue with Python 2.6 in the Trollius project.

Lib/asyncio/base_events.py

index 07d49c5e4dceaafe7aea717409b4a302673ce299..72201aa590f9e09398df6841d91a67133978d173 100644 (file)
@@ -614,12 +614,15 @@ class BaseEventLoop(events.AbstractEventLoop):
             t0 = self.time()
             event_list = self._selector.select(timeout)
             t1 = self.time()
-            argstr = '' if timeout is None else ' {:.3f}'.format(timeout)
             if t1-t0 >= 1:
                 level = logging.INFO
             else:
                 level = logging.DEBUG
-            logger.log(level, 'poll%s took %.3f seconds', argstr, t1-t0)
+            if timeout is not None:
+                logger.log(level, 'poll %.3f took %.3f seconds',
+                           timeout, t1-t0)
+            else:
+                logger.log(level, 'poll took %.3f seconds', t1-t0)
         else:
             event_list = self._selector.select(timeout)
         self._process_events(event_list)