-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcelery_config.py
More file actions
35 lines (27 loc) · 822 Bytes
/
celery_config.py
File metadata and controls
35 lines (27 loc) · 822 Bytes
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
28
29
30
31
32
33
34
35
from dotenv import load_dotenv
import pymysql
import os
import ssl
from celery import Celery
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
pymysql.install_as_MySQLdb()
load_dotenv()
DATABASE_URL = os.getenv("CELERY_DATABASE_URL")
engine = create_engine(DATABASE_URL, echo=True)
LocalSession = sessionmaker(autocommit=False, autoflush=False, bind=engine)
celery_app = Celery(
"pubsub_listener",
broker=os.getenv("CELERY_REDIS_URL"),
backend=os.getenv("CELERY_REDIS_URL"),
)
# celery_app.conf.broker_use_ssl = {"ssl_cert_reqs": ssl.CERT_REQUIRED}
broker_connection_retry_on_startup = True
celery_app.conf.update(
task_serializer="json",
accept_content=["json"],
result_serializer="json",
timezone="UTC",
enable_utc=True,
)
from jobs import payment_jobs