File tree Expand file tree Collapse file tree 6 files changed +20
-16
lines changed Expand file tree Collapse file tree 6 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -882,19 +882,26 @@ def _run_once(self):
882
882
when = self ._scheduled [0 ]._when
883
883
timeout = max (0 , when - self .time ())
884
884
885
- if self ._debug :
885
+ if self ._debug and timeout != 0 :
886
886
t0 = self .time ()
887
887
event_list = self ._selector .select (timeout )
888
888
dt = self .time () - t0
889
- if dt >= 1 :
889
+ if dt >= 1.0 :
890
890
level = logging .INFO
891
891
else :
892
892
level = logging .DEBUG
893
- if timeout is not None :
894
- logger .log (level , 'poll %.3f took %.3f seconds' ,
895
- timeout , dt )
896
- else :
897
- logger .log (level , 'poll took %.3f seconds' , dt )
893
+ nevent = len (event_list )
894
+ if timeout is None :
895
+ logger .log (level , 'poll took %.3f ms: %s events' ,
896
+ dt * 1e3 , nevent )
897
+ elif nevent :
898
+ logger .log (level ,
899
+ 'poll %.3f ms took %.3f ms: %s events' ,
900
+ timeout * 1e3 , dt * 1e3 , nevent )
901
+ elif dt >= 1.0 :
902
+ logger .log (level ,
903
+ 'poll %.3f ms took %.3f ms: timeout' ,
904
+ timeout * 1e3 , dt * 1e3 )
898
905
else :
899
906
event_list = self ._selector .select (timeout )
900
907
self ._process_events (event_list )
Original file line number Diff line number Diff line change 14
14
from . import events
15
15
from . import futures
16
16
from . import protocols
17
- from . import tasks
18
17
from .coroutines import coroutine
19
18
20
19
Original file line number Diff line number Diff line change 18
18
from . import events
19
19
from . import futures
20
20
from .coroutines import coroutine
21
- from .log import logger
22
21
23
22
_PY34 = (sys .version_info >= (3 , 4 ))
24
23
Original file line number Diff line number Diff line change 12
12
13
13
import asyncio
14
14
from asyncio import base_events
15
- from asyncio import events
16
15
from asyncio import constants
17
16
from asyncio import test_utils
18
17
@@ -26,6 +25,7 @@ class BaseEventLoopTests(test_utils.TestCase):
26
25
def setUp (self ):
27
26
self .loop = base_events .BaseEventLoop ()
28
27
self .loop ._selector = mock .Mock ()
28
+ self .loop ._selector .select .return_value = ()
29
29
self .set_event_loop (self .loop )
30
30
31
31
def test_not_implemented (self ):
Original file line number Diff line number Diff line change @@ -715,7 +715,7 @@ def test_create_unix_server_path_socket_error(self):
715
715
with self .assertRaisesRegex (ValueError ,
716
716
'path and sock can not be specified '
717
717
'at the same time' ):
718
- server = self .loop .run_until_complete (f )
718
+ self .loop .run_until_complete (f )
719
719
720
720
def _create_ssl_context (self , certfile , keyfile = None ):
721
721
sslcontext = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
Original file line number Diff line number Diff line change 1
1
"""Tests for tasks.py."""
2
2
3
- import os .path
4
3
import re
5
4
import sys
6
5
import types
@@ -1640,9 +1639,9 @@ def coro_noop():
1640
1639
asyncio .coroutines ._DEBUG = debug
1641
1640
1642
1641
tb_filename = __file__
1643
- tb_lineno = sys ._getframe ().f_lineno + 1
1644
- coro = coro_noop ()
1645
- coro = None
1642
+ tb_lineno = sys ._getframe ().f_lineno + 2
1643
+ # create a coroutine object but don't use it
1644
+ coro_noop ()
1646
1645
support .gc_collect ()
1647
1646
1648
1647
self .assertTrue (m_log .error .called )
@@ -1652,7 +1651,7 @@ def coro_noop():
1652
1651
r'Coroutine object created at \(most recent call last\):\n'
1653
1652
r'.*\n'
1654
1653
r' File "%s", line %s, in test_coroutine_never_yielded\n'
1655
- r' coro = coro_noop\(\)$'
1654
+ r' coro_noop\(\)$'
1656
1655
% (re .escape (coro_noop .__qualname__ ),
1657
1656
re .escape (func_filename ), func_lineno ,
1658
1657
re .escape (tb_filename ), tb_lineno ))
You can’t perform that action at this time.
0 commit comments