예제 #1
0
파일: queues.py 프로젝트: soutys/qeez_stats
def pull_all_stat_res(stat, redis_conn=None):
    '''Pulls all stat results
    '''
    if redis_conn is None:
        redis_conn = get_redis(CFG['QUEUE_REDIS'])
    queue = Queue('calc', connection=redis_conn)
    job = queue.fetch_job(COLL_ID_FMT % stat)

    res = None
    if job is None:
        return
    res = job.result
    if res is None:
        return

    out = []
    for stat_token in res:
        _job = queue.fetch_job(to_str(stat_token))
        _res = None
        if _job is not None:
            _res = _job.result
        if _res is not None:
            out.append(_res)

    return out
예제 #2
0
def pull_all_stat_res(stat, redis_conn=None):
    '''Pulls all stat results
    '''
    if redis_conn is None:
        redis_conn = get_redis(CFG['QUEUE_REDIS'])
    queue = Queue('calc', connection=redis_conn)
    job = queue.fetch_job(COLL_ID_FMT % stat)

    res = None
    if job is None:
        return
    res = job.result
    if res is None:
        return

    out = []
    for stat_token in res:
        _job = queue.fetch_job(to_str(stat_token))
        _res = None
        if _job is not None:
            _res = _job.result
        if _res is not None:
            out.append(_res)

    return out
예제 #3
0
파일: queues.py 프로젝트: soutys/qeez_stats
def enqueue_stat_save(qeez_token, res_dc, atime=None, redis_conn=None):
    '''Enqueues stat for save
    '''
    if atime is None:
        atime = gmtime()
    if redis_conn is None:
        redis_conn = get_redis(CFG['SAVE_REDIS'])
    queue = Queue('save', connection=redis_conn)
    return queue.enqueue(
        CFG['STAT_SAVE_FN'], args=(qeez_token, atime, res_dc),
        timeout=30, result_ttl=30, ttl=-1)
예제 #4
0
def enqueue_stat_save(qeez_token, res_dc, atime=None, redis_conn=None):
    '''Enqueues stat for save
    '''
    if atime is None:
        atime = gmtime()
    if redis_conn is None:
        redis_conn = get_redis(CFG['SAVE_REDIS'])
    queue = Queue('save', connection=redis_conn)
    return queue.enqueue(
        CFG['STAT_SAVE_FN'], args=(qeez_token, atime, res_dc),
        timeout=30, result_ttl=30, ttl=-1)
예제 #5
0
파일: queues.py 프로젝트: soutys/qeez_stats
def pull_stat_res(stat, qeez_token, redis_conn=None):
    '''Pulls one stat's result
    '''
    if redis_conn is None:
        redis_conn = get_redis(CFG['QUEUE_REDIS'])
    queue = Queue('calc', connection=redis_conn)
    job = queue.fetch_job(STAT_ID_FMT % (stat, qeez_token))
    res = None
    if job is not None:
        res = job.result
    if res is not None:
        job.ttl = job.result_ttl = 24 * 3600
        job.save()
    return res
예제 #6
0
파일: queues.py 프로젝트: soutys/qeez_stats
def enqueue_stat_calc(stat, qeez_token, redis_conn=None):
    '''Enqueues stat for calc
    '''
    if redis_conn is None:
        redis_conn = get_redis(CFG['QUEUE_REDIS'])
    stat_token = STAT_ID_FMT % (stat, qeez_token)
    queue = Queue('calc', connection=redis_conn)
    stat_append = queue.enqueue(
        stat_collector, stat, stat_token, timeout=30, result_ttl=-1,
        ttl=-1, job_id=COLL_ID_FMT % stat)
    _ = stat_append.id
    return queue.enqueue(
        stat, qeez_token, timeout=30, result_ttl=-1,
        ttl=-1, job_id=stat_token, depends_on=stat_append)
예제 #7
0
def pull_stat_res(stat, qeez_token, redis_conn=None):
    '''Pulls one stat's result
    '''
    if redis_conn is None:
        redis_conn = get_redis(CFG['QUEUE_REDIS'])
    queue = Queue('calc', connection=redis_conn)
    job = queue.fetch_job(STAT_ID_FMT % (stat, qeez_token))
    res = None
    if job is not None:
        res = job.result
    if res is not None:
        job.ttl = job.result_ttl = 24 * 3600
        job.save()
    return res
예제 #8
0
def enqueue_stat_calc(stat, qeez_token, redis_conn=None):
    '''Enqueues stat for calc
    '''
    if redis_conn is None:
        redis_conn = get_redis(CFG['QUEUE_REDIS'])
    stat_token = STAT_ID_FMT % (stat, qeez_token)
    queue = Queue('calc', connection=redis_conn)
    stat_append = queue.enqueue(
        stat_collector, stat, stat_token, timeout=30, result_ttl=-1,
        ttl=-1, job_id=COLL_ID_FMT % stat)
    _ = stat_append.id
    return queue.enqueue(
        stat, qeez_token, timeout=30, result_ttl=-1,
        ttl=-1, job_id=stat_token, depends_on=stat_append)