Celery tests

This commit is contained in:
Martyn Inglis
2016-02-09 13:31:45 +00:00
parent 1a7c521ebb
commit fb41acdac9
9 changed files with 84 additions and 5 deletions

21
app/celery/celery.py Normal file
View File

@@ -0,0 +1,21 @@
from celery import Celery
class NotifyCelery(Celery):
def init_app(self, app):
super().__init__(app.import_name, broker=app.config['BROKER_URL'])
self.conf.update(app.config)
TaskBase = self.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
self.Task = ContextTask