Пример #1
0
def execute_with_timeout(*args, **kwargs):
    time = kwargs.get('timeout', 30)

    def cb_timeout():
        msg = _("Time out after waiting"
                " %(time)s seconds when running proc: %(args)s"
                " %(kwargs)s") % locals()
        LOG.error(msg)
        raise exception.ProcessExecutionError(msg)

    timeout = Timeout(time)
    try:
        return execute(*args, **kwargs)
    except Timeout as t:
        if t is not timeout:
            LOG.error("Timeout reached but not from our timeout. This is bad!")
            raise
        else:
            msg = _("Time out after waiting "
                    "%(time)s seconds when running proc: %(args)s"
                    " %(kwargs)s") % locals()
            LOG.error(msg)
            raise exception.ProcessExecutionError(msg)
    finally:
        timeout.cancel()
Пример #2
0
 def cb_timeout():
     msg = _("Time out after waiting"
             " %(time)s seconds when running proc: %(args)s"
             " %(kwargs)s") % locals()
     LOG.error(msg)
     raise exception.ProcessExecutionError(msg)