Skip to content

Instantly share code, notes, and snippets.

@syedjafer
Created May 15, 2021 09:07
Show Gist options
  • Save syedjafer/f14449b82340fe95accc1a59a8e69e3a to your computer and use it in GitHub Desktop.
Save syedjafer/f14449b82340fe95accc1a59a8e69e3a to your computer and use it in GitHub Desktop.
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