本文整理汇总了Python中pq.Queue.schedule方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.schedule方法的具体用法?Python Queue.schedule怎么用?Python Queue.schedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pq.Queue
的用法示例。
在下文中一共展示了Queue.schedule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestJobAdmin
# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import schedule [as 别名]
class TestJobAdmin(TransactionTestCase):
def setUp(self):
password = 'test'
user = User.objects.create_superuser('test', '[email protected]', password)
self.client.login(username=user.username, password=password)
self.q = Queue()
self.q.enqueue_call(say_hello, args=('you',))
self.q.enqueue_call(div_by_zero, args=(1,))
self.q.schedule(datetime(2099, 1, 1, tzinfo=utc), say_hello, 'later')
w = Worker.create(self.q)
w.work(burst=True)
self.q.enqueue_call(say_hello, args=('me',))
def test_changelist(self):
data = (
("failedjob", FailedJob),
("queuedjob", QueuedJob),
("dequeuedjob", DequeuedJob),
("scheduledjob", ScheduledJob),
)
for modelname, Model in data:
url = reverse("admin:pq_%s_changelist" % modelname)
response = self.client.get(url, follow=True)
msg = "%s != %s -> %s, url: %s" % (
response.status_code, 200, repr(Model), url
)
self.assertEqual(response.status_code, 200, msg)
示例2: TestJobAdmin
# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import schedule [as 别名]
class TestJobAdmin(TransactionTestCase):
def setUp(self):
password = "test"
user = User.objects.create_superuser("test", "[email protected]", password)
self.client.login(username=user.username, password=password)
self.q = Queue()
self.q.enqueue_call(say_hello, args=("you",))
self.q.enqueue_call(div_by_zero, args=(1,))
self.q.schedule(datetime(2099, 1, 1), say_hello, "later")
w = Worker.create(self.q)
w.work(burst=True)
self.q.enqueue_call(say_hello, args=("me",))
@params(
("failedjob", FailedJob), ("queuedjob", QueuedJob), ("dequeuedjob", DequeuedJob), ("scheduledjob", ScheduledJob)
)
def test_changelist(self, modelname, Model):
url = reverse("admin:pq_%s_changelist" % modelname)
response = self.client.get(url, follow=True)
self.failUnlessEqual(
response.status_code, 200, "%s != %s -> %s, url: %s" % (response.status_code, 200, repr(Model), url)
)