Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1580fe3

Browse files
committed
asyncio, Tulip issue 172: only log selector timing in debug mode
1 parent c082ee6 commit 1580fe3

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/asyncio/base_events.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,7 @@ def _run_once(self):
834834
when = self._scheduled[0]._when
835835
timeout = max(0, when - self.time())
836836

837-
# TODO: Instrumentation only in debug mode?
838-
if logger.isEnabledFor(logging.INFO):
837+
if self._debug:
839838
t0 = self.time()
840839
event_list = self._selector.select(timeout)
841840
dt = self.time() - t0

Lib/test/test_asyncio/test_base_events.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ def slow_select(timeout):
247247
time.sleep(1.0)
248248
return []
249249

250+
# logging needs debug flag
251+
self.loop.set_debug(True)
252+
250253
# Log to INFO level if timeout > 1.0 sec.
251254
self.loop._selector.select = slow_select
252255
self.loop._process_events = mock.Mock()

0 commit comments

Comments
 (0)