(app_name, job_id, queue=True, priority=None)
Calling code should obtain a lock first!
    If queue=False, do everything except queue (ie set state)
Calling code should obtain a lock first!
    If queue=False, do everything except queue (ie set state)
Calling code should obtain a lock first! If queue = False do everything except queue ( ie set state )
def _queue(app_name, job_id, queue=True, priority=None):
    """ Calling code should obtain a lock first!
    If queue=False, do everything except queue (ie set state)"""
    qbcli = shared.get_qbclient()
    log.info(
        'Creating and queueing new subtask',
        extra=dict(app_name=app_name, job_id=job_id, priority=priority))
    if dt.passes_filter(app_name, job_id):
        # hack: zookeeper doesn't like unicode
        if isinstance(job_id, six.string_types):
            job_id = str(job_id)
        set_state(app_name, job_id, pending=True)
        if queue:
            if priority:
                qbcli.LockingQueue(app_name).put(job_id, priority=priority)
            else:
                qbcli.LockingQueue(app_name).put(job_id)
        else:
            log.warn(
                'create a subtask but not actually queueing it', extra=dict(
                    app_name=app_name, job_id=job_id, priority=priority))
    else:
        log.info(
            'job invalid.  marking as skipped so it does not run',
            extra=dict(app_name=app_name, job_id=job_id))
        set_state(app_name, job_id, skipped=True)
def _queue ( app_name , job_id , queue = True , priority = None ) : qbcli = shared . get_qbclient ( ) log . info ( 'Creating and queueing new subtask' , extra = dict ( app_name = app_name , job_id = job_id , priority = priority ) ) if dt . passes_filter ( app_name , job_id ) : # hack: zookeeper doesn't like unicode if isinstance ( job_id , six . string_types ) : job_id = str ( job_id ) set_state ( app_name , job_id , pending = True ) if queue : if priority : qbcli . LockingQueue ( app_name ) . put ( job_id , priority = priority ) else : qbcli . LockingQueue ( app_name ) . put ( job_id ) else : log . warn ( 'create a subtask but not actually queueing it' , extra = dict ( app_name = app_name , job_id = job_id , priority = priority ) ) else : log . info ( 'job invalid.  marking as skipped so it does not run' , extra = dict ( app_name = app_name , job_id = job_id ) ) set_state ( app_name , job_id , skipped = True )