Beispiel #1
0
def _get_run_time(ri):
    if ri[0] is not None:
        try:
            executed = get_client_datetime() - parse_client_sdatetime(ri[0])
            executed = timedelta(seconds=int(executed.total_seconds()))
        except ValueError:
            executed = None
    else:
        executed = None
    if ri[1] == 'None':
        elapsed = None
    else:
        elapsed = timedelta(seconds=int(float(ri[1])))
    return executed, elapsed
Beispiel #2
0
def finish_run(path, err):
    logging.debug(u'finish_run {}'.format(path))
    key = u'run:{}'.format(path)
    if r.exists(key):
        _start_dt, total = r.hmget(key, 'start', 'total')
        logging.debug("_start_dt {}, total {}".format(_start_dt, total))
        if err is None:
            start_dt = parse_client_sdatetime(_start_dt)
            elapsed = (get_client_datetime() - start_dt).total_seconds()
            r.hmset(key, {'elapsed': elapsed, 'cur': total})
            return elapsed
        else:
            logging.debug(u"error {}".format(err))
            r.hmset(key, {'error': err})
    else:
        logging.debug(u'key {} not exist'.format(key))