當前位置: 首頁>>代碼示例>>Python>>正文


Python Job.create方法代碼示例

本文整理匯總了Python中pq.job.Job.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Job.create方法的具體用法?Python Job.create怎麽用?Python Job.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pq.job.Job的用法示例。


在下文中一共展示了Job.create方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
 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,代碼行數:9,代碼來源:test_queue.py

示例2: test_create_job_from_string_function

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
    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,代碼行數:10,代碼來源:test_job.py

示例3: setUp

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
 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,代碼行數:10,代碼來源:test_queue.py

示例4: test_create_instance_method_job

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
    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,代碼行數:11,代碼來源:test_job.py

示例5: test_job_get_schedule_options

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
 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,代碼行數:12,代碼來源:test_job.py

示例6: test_scheduled_job_create

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
 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,代碼行數:17,代碼來源:test_job.py

示例7: test_job_create

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
    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,代碼行數:17,代碼來源:test_job.py

示例8: test_work_is_unreadable

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
    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,代碼行數:24,代碼來源:test_worker.py

示例9: setUp

# 需要導入模塊: from pq.job import Job [as 別名]
# 或者: from pq.job.Job import create [as 別名]
 def setUp(self):
     self.job = Job.create(func=some_calculation, args=(3, 4), kwargs=dict(z=2))
開發者ID:JirkaV,項目名稱:django-pq,代碼行數:4,代碼來源:test_job.py


注:本文中的pq.job.Job.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。