Created
May 15, 2021 09:07
-
-
Save syedjafer/f14449b82340fe95accc1a59a8e69e3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery import signature | |
from celery import Celery | |
import json | |
app = Celery(name="tasks", | |
broker="redis://localhost:6379/0", | |
backend="db+sqlite:///db+sqlite3" | |
) | |
@app.task | |
def division(param1, param2): | |
return param2/param1 | |
@app.task | |
def success_handler(result): | |
print(task_id) | |
return task_id | |
@app.task | |
def error_handler(task_id): | |
print(task_id) | |
return task_id | |
sum_task = signature( | |
'callbacks.division', | |
args=(0, 1), | |
link=success_handler.s(), | |
link_error=error_handler.s() | |
) | |
sum_task.apply_async() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment