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


Python Queue.enqueue_call方法代码示例

本文整理汇总了Python中pq.Queue.enqueue_call方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.enqueue_call方法的具体用法?Python Queue.enqueue_call怎么用?Python Queue.enqueue_call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pq.Queue的用法示例。


在下文中一共展示了Queue.enqueue_call方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestRequeueAdminAction

# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import enqueue_call [as 别名]
class TestRequeueAdminAction(TestCase):
    def setUp(self):
        self.q = Queue()
        self.q.enqueue_call(div_by_zero, args=(1,))
        w = Worker.create(self.q)
        w.work(burst=True)

    def test_requeue_admin_action(self):
        self.assertEqual(0, len(Job.objects.filter(queue_id="default")))
        requeue_failed_jobs(None, None, Job.objects.filter(queue_id="failed"))
        self.assertEqual(0, len(Job.objects.filter(queue_id="failed")))
        self.assertEqual("test_pq.fixtures.div_by_zero", Job.objects.get(queue_id="default").func_name)
开发者ID:vladignatyev,项目名称:django-pq,代码行数:14,代码来源:test_admin.py

示例2: TestEnqueueAsyncFalse

# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import enqueue_call [as 别名]
class TestEnqueueAsyncFalse(TestCase):
    def setUp(self):
        self.q = Queue()

    def test_enqueue_async_false(self):
        job = self.q.enqueue(some_calculation, args=(2, 3), async=False)
        self.assertEqual(job.result, 6)

    def test_enqueue_call_async_false(self):
        job = self.q.enqueue_call(some_calculation, args=(2, 3), async=False)
        self.assertEqual(job.result, 6)

    def test_schedule_call_async_false(self):
        job = self.q.enqueue_call(some_calculation, args=(2, 3), async=False)
        self.assertEqual(job.result, 6)
开发者ID:oinopion,项目名称:django-pq,代码行数:17,代码来源:test_queue.py

示例3: TestJobAdmin

# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import enqueue_call [as 别名]
class TestJobAdmin(TransactionTestCase):
    def setUp(self):
        password = 'test'
        user = User.objects.create_superuser('test', '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

示例4: TestJobAdmin

# 需要导入模块: from pq import Queue [as 别名]
# 或者: from pq.Queue import enqueue_call [as 别名]
class TestJobAdmin(TestCase):
    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,))
        w = Worker.create(self.q)
        w.work(burst=True)
        self.q.enqueue_call(say_hello, args=("me",))

    @params(("failedjob", FailedJob), ("queuedjob", QueuedJob), ("dequeuedjob", DequeuedJob))
    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:vladignatyev,项目名称:django-pq,代码行数:21,代码来源:test_admin.py


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