August 2015
Intermediate to advanced
286 pages
5h 42m
English
In this recipe, we'll show you how to create and call a task using the Celery module. Celery provides the following methods that make a call to a task:
apply_async(args[, kwargs[, …]]): This task sends a task messagedelay(*args, **kwargs): This is a shortcut to send a task message, but does not support execution optionsThe delay method is better to use because it can be called as a regular function:
task.delay(arg1, arg2, kwarg1='x', kwarg2='y')
While using apply_async you should write:
task.apply_async (args=[arg1, arg2] kwargs={'kwarg1': 'x','kwarg2': 'y'})To perform this simple task, we implement the following two simple scripts:
### ## addTask.py :Executing a simple task ### from celery import Celery ...
Read now
Unlock full access