From 518152d97e5bab6a04339bcb6066684f6395189c Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Sun, 18 Dec 2022 13:36:54 +0200 Subject: [PATCH] Reload interval on class variable (#2633) --- sanic/mixins/startup.py | 2 +- sanic/worker/reloader.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sanic/mixins/startup.py b/sanic/mixins/startup.py index 860d34a0..79517257 100644 --- a/sanic/mixins/startup.py +++ b/sanic/mixins/startup.py @@ -825,7 +825,7 @@ class StartupMixin(metaclass=SanicMeta): reload_dirs: Set[Path] = primary.state.reload_dirs.union( *(app.state.reload_dirs for app in apps) ) - reloader = Reloader(monitor_pub, 1.0, reload_dirs, app_loader) + reloader = Reloader(monitor_pub, 0, reload_dirs, app_loader) manager.manage("Reloader", reloader, {}, transient=False) inspector = None diff --git a/sanic/worker/reloader.py b/sanic/worker/reloader.py index 89f2ef1f..b490c5b3 100644 --- a/sanic/worker/reloader.py +++ b/sanic/worker/reloader.py @@ -17,6 +17,8 @@ from sanic.worker.loader import AppLoader class Reloader: + INTERVAL = 1.0 # seconds + def __init__( self, publisher: Connection, @@ -25,7 +27,7 @@ class Reloader: app_loader: AppLoader, ): self._publisher = publisher - self.interval = interval + self.interval = interval or self.INTERVAL self.reload_dirs = reload_dirs self.run = True self.app_loader = app_loader