update test arena

This commit is contained in:
2026-01-04 16:15:37 +01:00
parent 9d2f2b65ae
commit 396a0555d9
22 changed files with 309 additions and 4906 deletions

View File

@@ -2,6 +2,10 @@ from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
import os
import threading
import time
import requests
import json
db = SQLAlchemy()
login_manager = LoginManager()
@@ -73,5 +77,23 @@ def create_app():
except Exception as e:
# Admin user might already exist, rollback and continue
db.session.rollback()
# Start background polling thread
def poll_jobs():
with app.app_context():
from app.models import Job
from app.routes.jobs import update_job_status_internal
while True:
try:
# Poll all jobs that are not finished
unfinished_jobs = Job.query.filter(Job.status.in_(['waiting', 'in_progress'])).all()
for job in unfinished_jobs:
update_job_status_internal(job)
except Exception as e:
print(f"[ERROR] Background polling error: {e}")
time.sleep(20)
polling_thread = threading.Thread(target=poll_jobs, daemon=True)
polling_thread.start()
return app