コード例 #1
0
def parents_completed(app_name, job_id, q, lock):
    """Ensure parents are completed and if they aren't, return False"""
    parents_completed, consume_queue, parent_lock = \
        qb.ensure_parents_completed(app_name=app_name, job_id=job_id)
    if parents_completed is False:
        if consume_queue:
            q.consume()
            parent_lock is not None and parent_lock.release()
        else:
            _send_to_back_of_queue(q=q, app_name=app_name, job_id=job_id)
        lock.release()
        return False
    else:
        assert parent_lock is None, "Code Error"
        return True
コード例 #2
0
def test_child_running_while_parent_pending_but_not_executing(
        app1, app2, job_id1):
    enqueue(app1, job_id1)
    enqueue(app2, job_id1)
    parents_completed, consume_queue, parent_lock = \
        qb.ensure_parents_completed(app2, job_id1)
    # ensure lock is obtained by ensure_parents_completed
    validate_one_queued_executing_task(app1, job_id1)
    validate_one_queued_task(app2, job_id1)
    nose.tools.assert_equal(parents_completed, False)
    # child should promise to remove itself from queue
    nose.tools.assert_equal(consume_queue, True)
    nose.tools.assert_is_instance(parent_lock, qb.BaseLock)
    # cleanup
    parent_lock.release()
コード例 #3
0
ファイル: runner.py プロジェクト: kszucs/stolos
def parents_completed(app_name, job_id, q, lock):
    """Ensure parents are completed and if they aren't, return False"""
    parents_completed, consume_queue, parent_lock = \
        qb.ensure_parents_completed(app_name=app_name, job_id=job_id)
    if parents_completed is False:
        if consume_queue:
            q.consume()
            parent_lock is not None and parent_lock.release()
        else:
            _send_to_back_of_queue(
                q=q, app_name=app_name, job_id=job_id)
        lock.release()
        return False
    else:
        assert parent_lock is None, "Code Error"
        return True
コード例 #4
0
def test_child_running_while_parent_pending_and_executing(
        app1, app2, job_id1):
    enqueue(app1, job_id1)
    enqueue(app2, job_id1)
    lock = qb.obtain_execute_lock(app1, job_id1)
    assert lock
    parents_completed, consume_queue, parent_lock = \
        qb.ensure_parents_completed(app2, job_id1)
    validate_one_queued_executing_task(app1, job_id1)
    validate_one_queued_task(app2, job_id1)
    nose.tools.assert_equal(parents_completed, False)
    # child should not promise to remove itself from queue
    nose.tools.assert_equal(consume_queue, False)
    nose.tools.assert_is_none(parent_lock)
    # cleanup
    lock.release()