Initial commit: stock market platform
This commit is contained in:
31
backend/celery_app/worker.py
Normal file
31
backend/celery_app/worker.py
Normal file
@@ -0,0 +1,31 @@
|
||||
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,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user