From: Victor Stinner Date: Sun, 22 Jun 2014 22:31:08 +0000 (+0200) Subject: asyncio, Tulip issue 172: only log selector timing in debug mode X-Git-Tag: v3.4.2rc1~340 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1580fe3fcebcfe0b657281a6a556975c072a5530;p=thirdparty%2FPython%2Fcpython.git asyncio, Tulip issue 172: only log selector timing in debug mode --- diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 0975bcb6fc3d..2f7f1979d3e8 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -834,8 +834,7 @@ class BaseEventLoop(events.AbstractEventLoop): when = self._scheduled[0]._when timeout = max(0, when - self.time()) - # TODO: Instrumentation only in debug mode? - if logger.isEnabledFor(logging.INFO): + if self._debug: t0 = self.time() event_list = self._selector.select(timeout) dt = self.time() - t0 diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index b238f4ea01f6..9fa3e6d25c55 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -247,6 +247,9 @@ class BaseEventLoopTests(test_utils.TestCase): time.sleep(1.0) return [] + # logging needs debug flag + self.loop.set_debug(True) + # Log to INFO level if timeout > 1.0 sec. self.loop._selector.select = slow_select self.loop._process_events = mock.Mock()