Harshit Ghosh commited on
Commit ·
ced4437
1
Parent(s): f772e3c
Fix Celery prefetching deadlock by enabling Fair Scheduling
Browse files
start.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
# Start Celery worker in background
|
| 4 |
# We use concurrency=2 to avoid memory overload on the 16GB free tier
|
| 5 |
-
celery -A tasks worker --loglevel=info --concurrency=2 -B &
|
| 6 |
CELERY_PID=$!
|
| 7 |
|
| 8 |
# Trap SIGTERM and SIGINT for graceful shutdown
|
|
|
|
| 2 |
|
| 3 |
# Start Celery worker in background
|
| 4 |
# We use concurrency=2 to avoid memory overload on the 16GB free tier
|
| 5 |
+
celery -A tasks worker --loglevel=info --concurrency=2 -O fair -B &
|
| 6 |
CELERY_PID=$!
|
| 7 |
|
| 8 |
# Trap SIGTERM and SIGINT for graceful shutdown
|
tasks.py
CHANGED
|
@@ -76,6 +76,8 @@ celery_app.conf.update(
|
|
| 76 |
task_time_limit=3600, # 1 hour hard limit
|
| 77 |
task_soft_time_limit=3300, # 55 min soft limit
|
| 78 |
result_expires=86400, # 24 hours
|
|
|
|
|
|
|
| 79 |
)
|
| 80 |
|
| 81 |
extra_conf: dict[str, Any] = {}
|
|
|
|
| 76 |
task_time_limit=3600, # 1 hour hard limit
|
| 77 |
task_soft_time_limit=3300, # 55 min soft limit
|
| 78 |
result_expires=86400, # 24 hours
|
| 79 |
+
worker_prefetch_multiplier=1, # Prevent long-running tasks from getting stuck behind each other
|
| 80 |
+
task_acks_late=True, # Only acknowledge task after it completely finishes
|
| 81 |
)
|
| 82 |
|
| 83 |
extra_conf: dict[str, Any] = {}
|