Reload interval on class variable (#2633)

This commit is contained in:
Adam Hopkins 2022-12-18 13:36:54 +02:00 committed by GitHub
parent 0e44e9cacb
commit 518152d97e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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