diff --git a/backend/TaskScheduler.py b/backend/TaskScheduler.py index fb21501..143d1ab 100644 --- a/backend/TaskScheduler.py +++ b/backend/TaskScheduler.py @@ -4,7 +4,8 @@ class TaskScheduler: - def __init__(self) -> None: + def __init__(self,app) -> None: + self.app=app return def start(self) -> None: @@ -13,7 +14,8 @@ def start(self) -> None: def loop(self) -> None: while True: time.sleep(60*5) - schedule.run_pending() + with self.app.app_context(): + schedule.run_pending() def add_Daily_Task(self, task, *args) -> None: if len(args) > 0: diff --git a/backend/main.py b/backend/main.py index 4c6ee5b..9d82230 100644 --- a/backend/main.py +++ b/backend/main.py @@ -33,7 +33,7 @@ db.convert_usernames_to_lower() db.add_aliases_if_non_existend() - taskScheduler = TaskScheduler.TaskScheduler() + taskScheduler = TaskScheduler.TaskScheduler(app) taskScheduler.add_Daily_Task(db.hide_inactive) if util.pretix_url is not None: db.enable_disable_pretix_user()