-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcelery.py
27 lines (24 loc) · 892 Bytes
/
celery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from celery import Celery # type: ignore
from kombu.utils.url import safequote # type: ignore
from fastapi_app import config
settings = config.get_settings()
broker_url = "sqs://{aws_access_key}:{aws_secret_key}@".format(
aws_access_key=safequote(settings.aws_access_key_id),
aws_secret_key=safequote(settings.aws_secret_access_key),
)
celery_app = Celery(
"fastapi_app_workers",
broker_url=broker_url,
result_backend=None,
task_default_queue="[queue-name].fifo",
include=["fastapi_app.background_tasks"],
broker_transport_options={
"predefined_queues": {
"[queue-name].fifo": {
"url": "https://sqs.us-east-1.amazonaws.com/[account_id]/[queue-name].fifo",
"access_key_id": settings.aws_access_key_id,
"secret_access_key": settings.aws_secret_access_key,
}
}
},
)