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


Python job.Job类代码示例

本文整理汇总了Python中pq.job.Job的典型用法代码示例。如果您正苦于以下问题:Python Job类的具体用法?Python Job怎么用?Python Job使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 def setUp(self):
     job = Job.create(func=div_by_zero, args=(1, 2, 3))
     job.origin = 'fake'
     job.timeout = 200
     job.save()
     self.job = job
     self.fq = get_failed_queue()
开发者ID:vladignatyev,项目名称:django-pq,代码行数:7,代码来源:test_queue.py

示例2: test_get_job_or_promise

    def test_get_job_or_promise(self):
        """Test get a promise of a job in the future"""

        job, promise, timeout = Job._get_job_or_promise(
            self.q.connection, self.q, self.timeout)
        self.assertLessEqual(timeout, self.timeout)
        self.assertIsNone(job)
        self.assertEqual(promise, self.q.name)
开发者ID:JirkaV,项目名称:django-pq,代码行数:8,代码来源:test_job.py

示例3: setUp

 def setUp(self):
     self.q = Queue()
     self.q.save()
     self.job = Job.create(
         func=say_hello,
         args=('Nick',),
         kwargs=dict(foo='bar')
     )
开发者ID:oinopion,项目名称:django-pq,代码行数:8,代码来源:test_queue.py

示例4: test_get_job_no_promise

    def test_get_job_no_promise(self):
        """Test get job and no promise"""

        job, promise, timeout = Job._get_job_or_promise(
            self.q.connection, self.q, self.timeout)
        self.assertEqual(timeout, self.timeout)
        self.assertEquals(job.id, self.job.id)
        self.assertIsNone(promise)
开发者ID:JirkaV,项目名称:django-pq,代码行数:8,代码来源:test_job.py

示例5: test_create_job_from_string_function

    def test_create_job_from_string_function(self):
        """Creation of jobs using string specifier."""
        job = Job.create(func='test_pq.fixtures.say_hello', args=('World',))

        # Job data is set
        self.assertEquals(job.func, say_hello)
        self.assertIsNone(job.instance)
        self.assertEquals(job.args, ('World',))
开发者ID:JirkaV,项目名称:django-pq,代码行数:8,代码来源:test_job.py

示例6: test_create_instance_method_job

    def test_create_instance_method_job(self):
        """Creation of jobs for instance methods."""
        c = Calculator(2)
        job = Job.create(func=c.calculate, args=(3, 4))

        # Job data is set
        self.assertEquals(job.func, c.calculate)
        self.assertEquals(job.instance, c)
        self.assertEquals(job.args, (3, 4))
开发者ID:JirkaV,项目名称:django-pq,代码行数:9,代码来源:test_job.py

示例7: test_job_get_schedule_options

 def test_job_get_schedule_options(self):
     """Test the job schedule property"""
     j = Job.create(
         do_nothing,
         interval=600,
         between='2-4',
         repeat=10,
         weekdays=(0,1,2)
         )
     self.assertIsNotNone(j.get_schedule_options())
开发者ID:JirkaV,项目名称:django-pq,代码行数:10,代码来源:test_job.py

示例8: test_get_no_job_no_promise

    def test_get_no_job_no_promise(self):
        """Test get no job and no promise"""

        # job is in the future beyond the current
        # worker timeout
        job, promise, timeout = Job._get_job_or_promise(
            self.q.connection, self.q, 1)
        self.assertEqual(timeout, 1)
        self.assertIsNone(job)
        self.assertIsNone(promise)
开发者ID:JirkaV,项目名称:django-pq,代码行数:10,代码来源:test_job.py

示例9: test_get_earlier_job_no_promise

 def test_get_earlier_job_no_promise(self):
     """Test get earlier job and no promise"""
     # Job enqueue after the first scheduled job
     # but to be exec ahead of the scheduled job
     now_job = self.q.enqueue(do_nothing)
     job, promise, timeout = Job._get_job_or_promise(
         self.q.connection, self.q, 60)
     # timeout should remain the same
     self.assertEqual(timeout, 60)
     self.assertEqual(now_job.id, job.id)
     self.assertIsNone(promise)
开发者ID:JirkaV,项目名称:django-pq,代码行数:11,代码来源:test_job.py

示例10: test_scheduled_job_create

 def test_scheduled_job_create(self):
     """ Test extra kwargs """
     dt = datetime(2013,1,1, tzinfo=utc)
     rd = relativedelta(months=1, days=-1)
     job = Job.create(func=some_calculation,
         args=(3, 4), kwargs=dict(z=2),
         scheduled_for = dt,
         repeat = -1,
         interval = rd,
         between = '0-24'
         )
     job.save()
     job = Job.objects.get(pk=job.id)
     self.assertEqual(rd, job.interval)
     self.assertEqual(dt, job.scheduled_for)
开发者ID:JirkaV,项目名称:django-pq,代码行数:15,代码来源:test_job.py

示例11: test_job_create

    def test_job_create(self):
        job = Job.create(func=some_calculation, args=(3, 4), kwargs=dict(z=2))

        self.assertIsNotNone(job.created_at)
        self.assertIsNotNone(job.description)
        self.assertIsNone(job.instance)

        # Job data is set...
        self.assertEquals(job.func, some_calculation)
        self.assertEquals(job.args, (3, 4))
        self.assertEquals(job.kwargs, {'z': 2})

        # ...but metadata is not
        self.assertIsNone(job.origin)
        self.assertIsNone(job.enqueued_at)
开发者ID:JirkaV,项目名称:django-pq,代码行数:15,代码来源:test_job.py

示例12: test_work_is_unreadable

    def test_work_is_unreadable(self):
        """Unreadable jobs are put on the failed queue."""

        self.assertEqual(self.fq.count, 0)
        self.assertEqual(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.assertEqual(self.q.count, 1)

        # All set, we're going to process it

        self.w.work(burst=True)  # should silently pass
        self.assertEqual(self.q.count, 0)
        self.assertEqual(self.fq.count, 1)
开发者ID:oinopion,项目名称:django-pq,代码行数:22,代码来源:test_worker.py

示例13: setUp

 def setUp(self):
     self.job = Job.create(func=some_calculation, args=(3, 4), kwargs=dict(z=2))
开发者ID:JirkaV,项目名称:django-pq,代码行数:2,代码来源:test_job.py


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