mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Celery tests
This commit is contained in:
0
app/celery/__init__.py
Normal file
0
app/celery/__init__.py
Normal file
21
app/celery/celery.py
Normal file
21
app/celery/celery.py
Normal 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
|
||||
|
||||
|
||||
|
||||
|
||||
9
app/celery/tasks.py
Normal file
9
app/celery/tasks.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from app import celery
|
||||
from app.dao.services_dao import get_model_services
|
||||
|
||||
|
||||
@celery.task(name="refresh-services")
|
||||
def refresh_services():
|
||||
print(get_model_services())
|
||||
for service in get_model_services():
|
||||
celery.control.add_consumer(str(service.id))
|
||||
Reference in New Issue
Block a user