Advertisement
maurobaraldi

Simple Celery Example

Feb 24th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. from celery import Celery, group
  2. from celery.result import GroupResult
  3.  
  4. app = Celery('tasks', backend='redis://localhost:6379', broker='redis://localhost:6379')
  5.  
  6. @app.task
  7. def add(x, y):
  8.     return x + y
  9.  
  10. job = group([
  11.     add.s(1, 1),
  12.     add.s(2, 2)
  13. ])
  14. result = job.apply_async()
  15. result.save()
  16.  
  17. saved_result = GroupResult.restore(result.id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement