32 lines
904 B
Python
32 lines
904 B
Python
from celery import Celery
|
|
from celery.schedules import crontab
|
|
import os
|
|
import sys
|
|
|
|
app = Celery(
|
|
"stock_worker",
|
|
broker=os.getenv("CELERY_BROKER_URL", "redis://localhost:6379/1"),
|
|
backend=os.getenv("REDIS_URL", "redis://localhost:6379/0"),
|
|
include=["celery_app.tasks.market_tasks"],
|
|
)
|
|
|
|
app.conf.timezone = "Asia/Shanghai"
|
|
app.conf.enable_utc = False
|
|
|
|
# Windows does not support the default prefork pool (fork syscall unavailable)
|
|
if sys.platform == "win32":
|
|
app.conf.worker_pool = "solo"
|
|
|
|
app.conf.beat_schedule = {
|
|
# Refresh heatmap cache every 30s during trading hours
|
|
"refresh-heatmap-30s": {
|
|
"task": "celery_app.tasks.market_tasks.refresh_heatmap_cache",
|
|
"schedule": 30.0,
|
|
},
|
|
# Refresh index data every minute
|
|
"refresh-indices-1m": {
|
|
"task": "celery_app.tasks.market_tasks.refresh_market_overview",
|
|
"schedule": 60.0,
|
|
},
|
|
}
|