本文整理汇总了Python中celery.events.state.Task类的典型用法代码示例。如果您正苦于以下问题:Python Task类的具体用法?Python Task怎么用?Python Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ready
def test_ready(self):
task = Task(uuid='abcdefg',
name='tasks.add')
task.event('received', time(), time())
self.assertFalse(task.ready)
task.event('succeeded', time(), time())
self.assertTrue(task.ready)
示例2: test_ready
def test_ready(self):
task = Task(uuid="abcdefg",
name="tasks.add")
task.on_received(timestamp=time())
self.assertFalse(task.ready)
task.on_succeeded(timestamp=time())
self.assertTrue(task.ready)
示例3: test_info
def test_info(self):
task = Task(uuid='abcdefg',
name='tasks.add',
args='(2, 2)',
kwargs='{}',
retries=2,
result=42,
eta=1,
runtime=0.0001,
expires=1,
parent_id='bdefc',
root_id='dedfef',
foo=None,
exception=1,
received=time() - 10,
started=time() - 8,
exchange='celery',
routing_key='celery',
succeeded=time())
assert sorted(list(task._info_fields)) == sorted(task.info().keys())
assert (sorted(list(task._info_fields + ('received',))) ==
sorted(task.info(extra=('received',))))
assert (sorted(['args', 'kwargs']) ==
sorted(task.info(['args', 'kwargs']).keys()))
assert not list(task.info('foo'))
示例4: test_ready
def test_ready(self):
task = Task(uuid='abcdefg',
name='tasks.add')
task.event('received', time(), time())
assert not task.ready
task.event('succeeded', time(), time())
assert task.ready
示例5: test_info
def test_info(self):
task = Task(
uuid="abcdefg",
name="tasks.add",
args="(2, 2)",
kwargs="{}",
retries=2,
result=42,
eta=1,
runtime=0.0001,
expires=1,
foo=None,
exception=1,
received=time() - 10,
started=time() - 8,
exchange="celery",
routing_key="celery",
succeeded=time(),
)
self.assertEqual(sorted(list(task._info_fields)), sorted(task.info().keys()))
self.assertEqual(sorted(list(task._info_fields + ("received",))), sorted(task.info(extra=("received",))))
self.assertEqual(sorted(["args", "kwargs"]), sorted(task.info(["args", "kwargs"]).keys()))
self.assertFalse(list(task.info("foo")))
示例6: test_merge
def test_merge(self):
task = Task()
task.on_failed(timestamp=time())
task.on_started(timestamp=time())
task.on_received(timestamp=time(), name='tasks.add', args=(2, 2))
self.assertEqual(task.state, states.FAILURE)
self.assertEqual(task.name, 'tasks.add')
self.assertTupleEqual(task.args, (2, 2))
task.on_retried(timestamp=time())
self.assertEqual(task.state, states.RETRY)
示例7: test_merge
def test_merge(self):
task = Task()
task.event("failed", time(), time())
task.event("started", time(), time())
task.event("received", time(), time(), {"name": "tasks.add", "args": (2, 2)})
self.assertEqual(task.state, states.FAILURE)
self.assertEqual(task.name, "tasks.add")
self.assertTupleEqual(task.args, (2, 2))
task.event("retried", time(), time())
self.assertEqual(task.state, states.RETRY)
示例8: test_merge
def test_merge(self):
task = Task()
task.event('failed', time(), time())
task.event('started', time(), time())
task.event('received', time(), time(), {
'name': 'tasks.add', 'args': (2, 2),
})
self.assertEqual(task.state, states.FAILURE)
self.assertEqual(task.name, 'tasks.add')
self.assertTupleEqual(task.args, (2, 2))
task.event('retried', time(), time())
self.assertEqual(task.state, states.RETRY)
示例9: test_merge
def test_merge(self):
task = Task()
task.event('failed', time(), time())
task.event('started', time(), time())
task.event('received', time(), time(), {
'name': 'tasks.add', 'args': (2, 2),
})
assert task.state == states.FAILURE
assert task.name == 'tasks.add'
assert task.args == (2, 2)
task.event('retried', time(), time())
assert task.state == states.RETRY
示例10: test_info
def test_info(self):
task = Task(uuid='abcdefg',
name='tasks.add',
args='(2, 2)',
kwargs='{}',
retries=2,
result=42,
eta=1,
runtime=0.0001,
expires=1,
exception=1,
received=time() - 10,
started=time() - 8,
succeeded=time())
self.assertEqual(sorted(list(task._info_fields)),
sorted(task.info().keys()))
self.assertEqual(sorted(list(task._info_fields + ('received', ))),
sorted(task.info(extra=('received', ))))
self.assertEqual(sorted(['args', 'kwargs']),
sorted(task.info(['args', 'kwargs']).keys()))
示例11: test_info
def test_info(self):
task = Task(uuid="abcdefg",
name="tasks.add",
args="(2, 2)",
kwargs="{}",
retries=2,
result=42,
eta=1,
runtime=0.0001,
expires=1,
exception=1,
received=time() - 10,
started=time() - 8,
succeeded=time())
self.assertItemsEqual(list(task._info_fields),
task.info().keys())
self.assertItemsEqual(list(task._info_fields + ("received", )),
task.info(extra=("received", )))
self.assertItemsEqual(["args", "kwargs"],
task.info(["args", "kwargs"]).keys())
示例12: test_ready
def test_ready(self):
task = Task(uuid="abcdefg", name="tasks.add")
task.event("received", time(), time())
self.assertFalse(task.ready)
task.event("succeeded", time(), time())
self.assertTrue(task.ready)
示例13: test_sent
def test_sent(self):
task = Task(uuid='abcdefg',
name='tasks.add')
task.event('sent', time(), time())
assert task.state == states.PENDING
示例14: test_sent
def test_sent(self):
task = Task(uuid='abcdefg',
name='tasks.add')
task.on_sent(timestamp=time())
self.assertEqual(task.state, states.PENDING)
示例15: test_reduce_direct
def test_reduce_direct(self):
task = Task(uuid='uuid', name='tasks.add', args='(2, 2)')
fun, args = task.__reduce__()
task2 = fun(*args)
assert task == task2