npm run build错误修正

This commit is contained in:
hugo committed 2026-05-18 15:53:38 +08:00
1 parent 3d4b2647ae
commit 6a98cd89ec
3 files changed
+24 -14

No files matched your search

@@ -119,6 +119,14 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
db.session.add(run)
db.session.commit()
if task.cron_expr and trigger_type == "cron":
try:
iter = croniter(task.cron_expr, datetime.utcnow())
task.next_run_at = iter.get_next(datetime)
except Exception:
task.next_run_at = None
db.session.commit()
start_ts = time.time()
try:
executor = resolve_schedule_executor(task)
@@ -216,6 +224,13 @@ def start_scheduler(app):
if not bool(app.config.get("SCHEDULE_WORKER_ENABLED", True)):
return
import os
if os.environ.get('WERKZEUG_RUN_MAIN') == 'true' or not app.debug:
pass
else:
_worker_started = False
return
def _loop():
with app.app_context():
while True:
@@ -225,7 +240,7 @@ def start_scheduler(app):
ScheduleTask.enabled.is_(True),
ScheduleTask.next_run_at.isnot(None),
ScheduleTask.next_run_at <= now,
).limit(5).all()
).limit(5).with_for_update(skip_locked=True).all()
for task in due_tasks:
try:
run_task_now(task, trigger_type="cron", triggered_by_user_id=None)