def setGreedCoro(loop: asyncio.AbstractEventLoop): greedy_threshold = os.environ.get('SYN_GREEDY_CORO') if greedy_threshold is not None: # pragma: no cover logger.info( f'Setting ioloop.slow_callback_duration to {greedy_threshold}') loop.set_debug(True) loop.slow_callback_duration = float(greedy_threshold)
def enable_async_loop_debugging( event_loop: AbstractEventLoop) -> AbstractEventLoop: logging.info("Enabling coroutine debugging. Loop id {}.".format( id(asyncio.get_event_loop()))) # Enable debugging event_loop.set_debug(True) # Make the threshold for "slow" tasks very very small for # illustration. The default is 0.1 (= 100 milliseconds). event_loop.slow_callback_duration = 0.001 # Report all mistakes managing asynchronous resources. warnings.simplefilter("always", ResourceWarning) return event_loop
def enable_async_loop_debugging( event_loop: AbstractEventLoop, slow_callback_duration: float = 0.1) -> AbstractEventLoop: """Enables debugging on an event loop. Args: event_loop: The event loop to enable debugging on slow_callback_duration: The threshold at which a callback should be alerted as slow. """ logging.info("Enabling coroutine debugging. Loop id {}.".format( id(asyncio.get_event_loop()))) # Enable debugging event_loop.set_debug(True) # Make the threshold for "slow" tasks very very small for # illustration. The default is 0.1 (= 100 milliseconds). event_loop.slow_callback_duration = slow_callback_duration # Report all mistakes managing asynchronous resources. warnings.simplefilter("always", ResourceWarning) return event_loop