File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -432,7 +432,6 @@ def __init__(self):
432432 # Identifier of the thread running the event loop, or None if the
433433 # event loop is not running
434434 self ._thread_id = None
435- self ._clock_resolution = time .get_clock_info ('monotonic' ).resolution
436435 self ._exception_handler = None
437436 self .set_debug (coroutines ._is_debug_mode ())
438437 # The preserved state of async generator hooks.
@@ -2057,7 +2056,7 @@ def _run_once(self):
20572056 now = self .time ()
20582057 # Ensure that `end_time` is strictly increasing
20592058 # when the clock resolution is too small.
2060- end_time = now + max (self . _clock_resolution , math .ulp (now ))
2059+ end_time = now + max (constants . CLOCK_RESOLUTION , math .ulp (now ))
20612060 while self ._scheduled :
20622061 handle = self ._scheduled [0 ]
20632062 if handle ._when >= end_time :
Original file line number Diff line number Diff line change 33# SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io
44
55import enum
6+ import time
67
78# After the connection is lost, log warnings after this many write()s.
89LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5
3334# Default timeout for joining the threads in the threadpool
3435THREAD_JOIN_TIMEOUT = 300
3536
37+ # Resolution of the clock used by the event loop, in seconds.
38+ CLOCK_RESOLUTION = time .get_clock_info ('monotonic' ).resolution
39+
3640# The enum should be here to break circular dependencies between
3741# base_events and sslproto
3842class _SendfileMode (enum .Enum ):
Original file line number Diff line number Diff line change 2727 import tty
2828
2929import asyncio
30+ from asyncio import constants
3031from asyncio import coroutines
3132from asyncio import events
3233from asyncio import selector_events
@@ -2314,7 +2315,7 @@ async def wait():
23142315 # of the clock used by the kernel. Tolerate a few useless calls on
23152316 # these platforms.
23162317 self .assertLessEqual (self .loop ._run_once_counter , 20 ,
2317- {'clock_resolution' : self . loop . _clock_resolution ,
2318+ {'clock_resolution' : constants . CLOCK_RESOLUTION ,
23182319 'selector' : self .loop ._selector .__class__ .__name__ })
23192320
23202321 def test_remove_fds_after_closing (self ):
Original file line number Diff line number Diff line change @@ -360,7 +360,6 @@ def gen():
360360 self ._gen = gen ()
361361 next (self ._gen )
362362 self ._time = 0
363- self ._clock_resolution = 1e-9
364363 self ._timers = []
365364 self ._selector = TestSelector ()
366365
You can’t perform that action at this time.
0 commit comments