Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. @shared_task
  2. def add(x, y):
  3.     return x + y
  4.  
  5. @shared_task
  6. def tsum(numbers):
  7.     return sum(numbers)
  8.  
  9. @shared_task
  10. def all_in_one():
  11.     return chord(
  12.         (add.s(x, x*2) for x in range(0, 5)), tsum()
  13.     )()
  14.  
  15. def start():
  16.     result = all_in_one.delay()
  17.     print type(result)  # <class 'celery.result.AsyncResult'>
  18.     print result        # 05d8872b-9fd2-4b57-b9ae-57e9e9518a55
  19.     res = result.wait()
  20.     print type(res)     # <type 'list'>
  21.     print res           # [[u'f1ce1b79-28d0-4766-a741-8c49de337475', [[u'078c014e-0e04-414d-bc8f-c084ad1a7ab1', None], [[[u'256be58b-9758-4d46-98f9-985073b0a2bc', None], None], [[u'a708b813-a89d-48d6-beeb-f314168a4364', None], None], [[u'80f50bd8-e0b6-4ca5-b648-af65c0d994aa', None], None], [[u'847bd1cc-1d97-4d46-859f-0736a697af0d', None], None], [[u'0a12788d-15ce-41f1-afb1-790bc8672c20', None], None]]]], None]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement