本文整理汇总了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()
示例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',))
示例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')
)
示例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))
示例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())
示例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)
示例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)
示例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)
示例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))