当前位置: 首页>>代码示例>>Python>>正文


Python Queue.schedule方法代码示例

本文整理汇总了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)
开发者ID:oinopion,项目名称:django-pq,代码行数:29,代码来源:test_admin.py

示例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)
        )
开发者ID:bretth,项目名称:django-pq,代码行数:24,代码来源:test_admin.py


注:本文中的pq.Queue.schedule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。