@@ -634,12 +634,25 @@ def _run_once(self):
634634 else :
635635 logger .log (level , 'poll took %.3f seconds' , t1 - t0 )
636636 else :
637- t0 = self .time ()
637+ t0_monotonic = time .monotonic ()
638+ t0 = time .perf_counter ()
638639 event_list = self ._selector .select (timeout )
639- dt = self .time () - t0
640- if not event_list and timeout and dt < timeout :
641- print ("asyncio: selector.select(%.3f ms) took %.3f ms"
642- % (timeout * 1e3 , dt * 1e3 ),
640+ dt = time .perf_counter () - t0
641+ dt_monotonic = time .monotonic () - t0_monotonic
642+ if not event_list and timeout : # and dt < timeout:
643+ selector = self ._selector .__class__ .__name__
644+ if (selector .startswith (("Poll" , "Epoll" , "Iocp" ))
645+ or timeout > 1e-3 or dt > 1e-3 ):
646+ unit , factor = "ms" , 1e3
647+ else :
648+ unit , factor = "us" , 1e6
649+ print ("asyncio: %s.select(%.3f %s) took %.3f %s"
650+ " (monotonic: %.3f %s, clock res: %.3f %s)"
651+ % (self ._selector .__class__ .__name__ ,
652+ timeout * factor , unit ,
653+ dt * factor , unit ,
654+ dt_monotonic * factor , unit ,
655+ self ._clock_resolution * factor , unit ),
643656 file = sys .__stderr__ , flush = True )
644657 self ._process_events (event_list )
645658
0 commit comments