[UPDT] BASE: Scheduler start function call updated by adding sys.argv condition

This commit is contained in:
Horilla
2025-01-03 16:11:04 +05:30
parent 53728e154d
commit 9542567aec
4 changed files with 38 additions and 151 deletions

View File

@@ -1,4 +1,5 @@
import datetime
import sys
from datetime import timedelta
from apscheduler.schedulers.background import BackgroundScheduler
@@ -131,7 +132,13 @@ def block_unblock_disciplinary():
return
scheduler = BackgroundScheduler()
scheduler.add_job(update_experience, "interval", hours=4)
scheduler.add_job(block_unblock_disciplinary, "interval", seconds=25)
scheduler.start()
if not any(
cmd in sys.argv for cmd in ["makemigrations", "migrate", "compilemessages", "flush"]
):
"""
Initializes and starts background tasks using APScheduler when the server is running.
"""
scheduler = BackgroundScheduler()
scheduler.add_job(update_experience, "interval", hours=4)
scheduler.add_job(block_unblock_disciplinary, "interval", seconds=25)
scheduler.start()