From 06b7ef90fa312e0691fe532bf2f367ee00a7d17a Mon Sep 17 00:00:00 2001 From: Philipp Mandler Date: Tue, 12 Dec 2023 18:07:22 +0100 Subject: [PATCH] Do not reload worker when models change --- worker/run.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/worker/run.py b/worker/run.py index 0527ad87..b84f9b67 100644 --- a/worker/run.py +++ b/worker/run.py @@ -57,7 +57,11 @@ def main(): stop_watching_event = asyncio.Event() p = run_sync_in_process(stop_watching_event, args) - for _ in watch(path, stop_event=stop_watching_event): + def watch_filter(change, path: str): + # do not reload when models are downloaded + return not path.startswith(settings.MODELS_DIR.absolute().as_posix()) + + for _ in watch(path, watch_filter=watch_filter, stop_event=stop_watching_event): logging.info("Source code change detected, reloading worker") p.terminate() p.join()