コード例 #1
0
ファイル: glob.py プロジェクト: wesinator/synapse
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)
コード例 #2
0
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
コード例 #3
0
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