コード例 #1
0
def wait(predicate, log=True, **kwargs):
    __tracebackhide__ = True

    frame = inspect.stack()[1]
    called_from = '{0.f_globals[__name__]}:{2}'.format(*frame)
    event = kwargs.get('waiting_for', repr(predicate))
    msg = '{called_from}: waiting for {event}'.format(event=event,
                                                      called_from=called_from)
    logger = logging.getLogger('waiting')

    if log:
        logger.info(msg)

    start = time()

    try:
        result = base_wait(predicate, **kwargs)
        if log:
            logger.info('{msg} ... done. '
                        'Took {time:.0f}s'.format(msg=msg,
                                                  time=time() - start))
        return result
    except TimeoutExpired as e:
        # prevent shows traceback from waiting package
        raise e
コード例 #2
0
def wait(*args, **kwargs):
    __tracebackhide__ = True
    waiting_for = kwargs.get('waiting_for', args[0].__name__)
    logger.info('waiting for {}'.format(waiting_for))

    try:
        result = base_wait(*args, **kwargs)
        logger.info('waiting for {} ... done'.format(waiting_for))
        return result
    except TimeoutExpired as e:
        raise e
コード例 #3
0
def wait(*args, **kwargs):
    __tracebackhide__ = True

    frame = inspect.stack()[1]
    called_from = '{0.f_globals[__name__]}:{2}'.format(*frame)
    event = kwargs.get('waiting_for', args[0].__name__)
    msg = '{called_from}: waiting for {event}'.format(event=event,
                                                      called_from=called_from)
    logger = logging.getLogger('waiting')

    logger.info(msg)

    try:
        result = base_wait(*args, **kwargs)
        logger.info(msg + ' ... done')
        return result
    except TimeoutExpired as e:
        # prevent shows traceback from waiting package
        raise e
コード例 #4
0
def wait(*args, **kwargs):
    __tracebackhide__ = True

    frame = inspect.stack()[1]
    called_from = '{0.f_globals[__name__]}:{2}'.format(*frame)
    event = kwargs.get('waiting_for', args[0].__name__)
    msg = '{called_from}: waiting for {event}'.format(event=event,
                                                      called_from=called_from)
    logger = logging.getLogger('waiting')

    logger.info(msg)

    try:
        result = base_wait(*args, **kwargs)
        logger.info(msg + ' ... done')
        return result
    except TimeoutExpired as e:
        # prevent shows traceback from waiting package
        raise e
コード例 #5
0
def wait(*args, **kwargs):
    __tracebackhide__ = True
    try:
        return base_wait(*args, **kwargs)
    except TimeoutExpired as e:
        raise e