ayushkhare12

Untitled

Aug 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1.  from celery import Celery
  2.  
  3. def make_celery(app):
  4.     celery = Celery(
  5.     'test-cargill',
  6.     broker=app.config['CELERY_BROKER_URL'],
  7.     config_source={
  8.         'broker_transport_options': {
  9.             'never_list_queues': True,
  10.             'predefined_queue_urls': {
  11.                 'test-cargill': 'https://sqs.us-east-1.amazonaws.com/469960938340/test-cargill' ,
  12.             },
  13.         },
  14.         'task_default_queue': 'test-cargill',
  15.     },
  16. )
  17.     celery.conf.update(app.config)
  18.  
  19.     class ContextTask(celery.Task):
  20.         def __call__(self, *args, **kwargs):
  21.             with app.app_context():
  22.                 return self.run(*args, **kwargs)
  23.  
  24.     celery.Task = ContextTask
  25.     return celery
Add Comment
Please, Sign In to add comment