tests/task/simulate.py
def stop_task_pool(pool, max_wait_time=5, sleep_interval=1):
    '''
    Shuts down the provided task `Pool` and waits for the workers to exit.

    The `max_wait_time` and `sleep_interval` parameters work the same as they
    do in `process_task_pool`.
    '''
    if not isinstance(max_wait_time, (int, float)):
        raise TypeError('max wait time must be a number: %r' % (max_wait_time))
    if not isinstance(pool, Pool):
        raise TypeError('task pool must be a Pool: %r' % (pool))

    no_timeout = (max_wait_time == 0)
    if no_timeout:
        raise NotImplementedError

    logger.debug(
        'waiting %r seconds in %r second intervals for pool to shutdown',
        max_wait_time, sleep_interval,
    )

    # not the most elegant solution, but fairly reliable
    current_wait_time = 0
    while current_wait_time < max_wait_time:
        if pool.shutdown(wait=True, timeout=0):
            logger.debug('task pool has shut down! returning')
            return

        logger.debug(
            'task pool still has running workers, waiting %rs', sleep_interval,
        )
        time.sleep(sleep_interval)
        current_wait_time += sleep_interval

    if current_wait_time >= max_wait_time:
        raise TimeoutError(
            'shutdown time exceeded %r seconds' % (max_wait_time)
        )

    Shuts down the provided task `Pool` and waits for the workers to exit.

    The `max_wait_time` and `sleep_interval` parameters work the same as they
    do in `process_task_pool`.
    
Shuts down the provided task `Pool` and waits for the workers to exit.
Shuts down the provided task ` Pool ` and waits for the workers to exit .
def stop_task_pool(pool, max_wait_time=5, sleep_interval=1):
    if not isinstance(max_wait_time, (int, float)):
        raise TypeError('max wait time must be a number: %r' % (max_wait_time))
    if not isinstance(pool, Pool):
        raise TypeError('task pool must be a Pool: %r' % (pool))
    no_timeout = (max_wait_time == 0)
    if no_timeout:
        raise NotImplementedError
    logger.debug(
        'waiting %r seconds in %r second intervals for pool to shutdown',
        max_wait_time, sleep_interval,
    )
    current_wait_time = 0
    while current_wait_time < max_wait_time:
        if pool.shutdown(wait=True, timeout=0):
            logger.debug('task pool has shut down! returning')
            return
        logger.debug(
            'task pool still has running workers, waiting %rs', sleep_interval,
        )
        time.sleep(sleep_interval)
        current_wait_time += sleep_interval
    if current_wait_time >= max_wait_time:
        raise TimeoutError(
            'shutdown time exceeded %r seconds' % (max_wait_time)
        )
def stop_task_pool ( pool , max_wait_time = 5 , sleep_interval = 1 ) : if not isinstance ( max_wait_time , ( int , float ) ) : raise TypeError ( 'max wait time must be a number: %r' % ( max_wait_time ) ) if not isinstance ( pool , Pool ) : raise TypeError ( 'task pool must be a Pool: %r' % ( pool ) ) no_timeout = ( max_wait_time == 0 ) if no_timeout : raise NotImplementedError logger . debug ( 'waiting %r seconds in %r second intervals for pool to shutdown' , max_wait_time , sleep_interval , ) current_wait_time = 0 while current_wait_time < max_wait_time : if pool . shutdown ( wait = True , timeout = 0 ) : logger . debug ( 'task pool has shut down! returning' ) return logger . debug ( 'task pool still has running workers, waiting %rs' , sleep_interval , ) time . sleep ( sleep_interval ) current_wait_time += sleep_interval if current_wait_time >= max_wait_time : raise TimeoutError ( 'shutdown time exceeded %r seconds' % ( max_wait_time ) )
Shuts down the provided task `Pool` and waits for the workers to exit.
Shuts down the provided task ` Pool ` and waits for the workers to exit .
'''
    Shuts down the provided task `Pool` and waits for the workers to exit.

    The `max_wait_time` and `sleep_interval` parameters work the same as they
    do in `process_task_pool`.
    ''' # not the most elegant solution, but fairly reliable
pool
max_wait_time
sleep_interval