當前位置: 首頁>>代碼示例>>Python>>正文


Python Queue.push_job_id方法代碼示例

本文整理匯總了Python中aiorq.Queue.push_job_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Queue.push_job_id方法的具體用法?Python Queue.push_job_id怎麽用?Python Queue.push_job_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aiorq.Queue的用法示例。


在下文中一共展示了Queue.push_job_id方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_dequeue_ignores_nonexisting_jobs

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import push_job_id [as 別名]
def test_dequeue_ignores_nonexisting_jobs():
    """Dequeuing silently ignores non-existing jobs."""

    q = Queue()
    uuid = '49f205ab-8ea3-47dd-a1b5-bfa186870fc8'
    yield from q.push_job_id(uuid)
    yield from q.push_job_id(uuid)
    result = yield from q.enqueue(say_hello, 'Nick', foo='bar')
    yield from q.push_job_id(uuid)

    # Dequeue simply ignores the missing job and returns None
    assert (yield from q.count) == 4
    assert (yield from q.dequeue()).id == result.id
    assert not (yield from q.dequeue())
    assert not (yield from q.count)
開發者ID:essobi,項目名稱:aiorq,代碼行數:17,代碼來源:test_queue.py

示例2: test_work_is_unreadable

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import push_job_id [as 別名]
def test_work_is_unreadable(redis, loop):
    """Unreadable jobs are put on the failed queue."""

    q = Queue()
    failed_q = get_failed_queue()

    assert (yield from failed_q.count) == 0
    assert (yield from q.count) == 0

    # NOTE: We have to fake this enqueueing for this test case.
    # What we're simulating here is a call to a function that is not
    # importable from the worker process.
    job = Job.create(func=say_hello, args=(3,))
    yield from job.save()

    # NOTE: replacement and original strings must have the same length
    data = yield from redis.hget(job.key, 'data')
    invalid_data = data.replace(b'say_hello', b'fake_attr')
    assert data != invalid_data
    yield from redis.hset(job.key, 'data', invalid_data)

    # We use the low-level internal function to enqueue any data
    # (bypassing validity checks)
    yield from q.push_job_id(job.id)

    assert (yield from q.count) == 1

    # All set, we're going to process it
    w = Worker([q])
    yield from w.work(burst=True, loop=loop)  # Should silently pass
    assert (yield from q.count) == 0
    assert (yield from failed_q.count) == 1
開發者ID:proofit404,項目名稱:aiorq,代碼行數:34,代碼來源:test_worker.py

示例3: test_dequeue_any_ignores_nonexisting_jobs

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import push_job_id [as 別名]
def test_dequeue_any_ignores_nonexisting_jobs():
    """Dequeuing (from any queue) silently ignores non-existing jobs."""

    q = Queue('low')
    uuid = '49f205ab-8ea3-47dd-a1b5-bfa186870fc8'
    yield from q.push_job_id(uuid)

    # Dequeue simply ignores the missing job and returns None
    assert (yield from q.count) == 1
    assert not (yield from Queue.dequeue_any([Queue(), Queue('low')], None))
    assert not (yield from q.count)
開發者ID:essobi,項目名稱:aiorq,代碼行數:13,代碼來源:test_queue.py

示例4: test_pop_job_id

# 需要導入模塊: from aiorq import Queue [as 別名]
# 或者: from aiorq.Queue import push_job_id [as 別名]
def test_pop_job_id():
    """Popping job IDs from queues."""

    # Set up
    q = Queue()
    uuid = '112188ae-4e9d-4a5b-a5b3-f26f2cb054da'
    yield from q.push_job_id(uuid)

    # Pop it off the queue...
    assert (yield from q.count)
    assert (yield from q.pop_job_id()) == uuid

    # ...and assert the queue count when down
    assert not (yield from q.count)
開發者ID:essobi,項目名稱:aiorq,代碼行數:16,代碼來源:test_queue.py


注:本文中的aiorq.Queue.push_job_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。