-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcelery_app.py
More file actions
39 lines (31 loc) · 1.01 KB
/
celery_app.py
File metadata and controls
39 lines (31 loc) · 1.01 KB
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
36
37
38
39
"""Celery application configuration for background tasks."""
import os
from celery import Celery
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
def make_celery():
"""Create and configure Celery application."""
# Get broker URL from environment (Redis)
broker_url = os.getenv('CELERY_BROKER_URL') or os.getenv('REDIS_URL', 'redis://localhost:6379/0')
# Handle Heroku Redis SSL
if broker_url.startswith('rediss://'):
broker_url += '?ssl_cert_reqs=none'
celery = Celery(
'wishlist',
broker=broker_url,
backend=broker_url,
include=['services.celery_tasks']
)
celery.conf.update(
task_serializer='json',
accept_content=['json'],
result_serializer='json',
timezone='UTC',
enable_utc=True,
task_track_started=True,
task_time_limit=300, # 5 minute timeout
worker_prefetch_multiplier=1, # One task at a time
)
return celery
celery_app = make_celery()