| Conditions | 2 |
| Total Lines | 15 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from celery import Celery |
||
| 7 | def create_celery(app): |
||
| 8 | celery = Celery(app.import_name, |
||
| 9 | backend=app.config['CELERY_RESULT_BACKEND'], |
||
| 10 | broker=app.config['BROKER_URL']) |
||
| 11 | celery.conf.update(app.config) |
||
| 12 | TaskBase = celery.Task |
||
| 13 | |||
| 14 | class ContextTask(TaskBase): |
||
| 15 | abstract = True |
||
| 16 | |||
| 17 | def __call__(self, *args, **kwargs): |
||
| 18 | with app.app_context(): |
||
| 19 | return TaskBase.__call__(self, *args, **kwargs) |
||
| 20 | celery.Task = ContextTask |
||
| 21 | return celery |
||
| 22 | |||
| 32 |