Spaces:
Sleeping
Sleeping
Update app/celery_app.py
Browse files- app/celery_app.py +22 -15
app/celery_app.py
CHANGED
|
@@ -1,18 +1,25 @@
|
|
| 1 |
from celery import Celery
|
| 2 |
from app.config import settings
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from celery import Celery
|
| 2 |
from app.config import settings
|
| 3 |
|
| 4 |
+
# Allow running without a broker (Queues disabled in Spaces preview)
|
| 5 |
+
if settings.CELERY_BROKER_URL:
|
| 6 |
+
celery = Celery(
|
| 7 |
+
"prir",
|
| 8 |
+
broker=settings.CELERY_BROKER_URL,
|
| 9 |
+
backend=settings.CELERY_RESULT_BACKEND or None,
|
| 10 |
+
)
|
| 11 |
+
celery.conf.update(
|
| 12 |
+
task_serializer="json",
|
| 13 |
+
accept_content=["json"],
|
| 14 |
+
result_serializer="json",
|
| 15 |
+
timezone="Asia/Tokyo",
|
| 16 |
+
enable_utc=True,
|
| 17 |
+
)
|
| 18 |
+
else:
|
| 19 |
+
# Dummy Celery shim for .delay/.apply_async to fail gracefully
|
| 20 |
+
class _Dummy:
|
| 21 |
+
def task(self, *a, **kw):
|
| 22 |
+
def deco(fn):
|
| 23 |
+
return fn
|
| 24 |
+
return deco
|
| 25 |
+
celery = _Dummy()
|