From a90cd39612ff0c7076fd537f019193a28afd9ed0 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 14 Nov 2023 12:51:33 -0500 Subject: [PATCH] doorcontrol: Register tasks in post migrate hook to fix uvicorn issue --- doorcontrol/apps.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doorcontrol/apps.py b/doorcontrol/apps.py index 4ef5da9..0938fb3 100644 --- a/doorcontrol/apps.py +++ b/doorcontrol/apps.py @@ -1,4 +1,11 @@ from django.apps import AppConfig +from django.db.models.signals import post_migrate + + +def post_migrate_callback(sender, **kwargs): + from .tasks.scrapehidevents import schedule_tasks + + schedule_tasks() class DoorControlConfig(AppConfig): @@ -7,6 +14,4 @@ class DoorControlConfig(AppConfig): verbose_name = "Door Control" def ready(self): - from .tasks.scrapehidevents import schedule_tasks - - schedule_tasks() + post_migrate.connect(post_migrate_callback, sender=self)