本文整理汇总了Python中pq.Queue.save方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.save方法的具体用法?Python Queue.save怎么用?Python Queue.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pq.Queue
的用法示例。
在下文中一共展示了Queue.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestWorkIsUnreadable
# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import save [as 别名]
class TestWorkIsUnreadable(TransactionTestCase):
def setUp(self):
self.q = Queue()
self.q.save()
self.fq = get_failed_queue()
self.w = Worker.create([self.q])
def test_work_is_unreadable(self):
"""Unreadable jobs are put on the failed queue."""
self.assertEquals(self.fq.count, 0)
self.assertEquals(self.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=div_by_zero, args=(3,))
job.save()
job.instance = 'nonexisting_job'
job.queue = self.q
job.save()
self.assertEquals(self.q.count, 1)
# All set, we're going to process it
self.w.work(burst=True) # should silently pass
self.assertEquals(self.q.count, 0)
self.assertEquals(self.fq.count, 1)
示例2: TestEnqueue
# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import save [as 别名]
class TestEnqueue(TransactionTestCase):
def setUp(self):
self.q = Queue()
self.q.save()
self.job = Job.create(func=say_hello, args=('Nick',), kwargs=dict(foo='bar'))
def test_enqueue_sets_metadata(self):
"""Enqueueing job onto queues modifies meta data."""
# Preconditions
self.assertIsNone(self.job.origin)
self.assertIsNone(self.job.enqueued_at)
# Action
self.q.enqueue_job(self.job)
# Postconditions
self.assertEquals(self.job.origin, self.q.name)
self.assertIsNotNone(self.job.enqueued_at)