From 8cb81dd07f75e873f845e98e4240378b026a5476 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Wed, 7 Aug 2024 15:38:30 +0100 Subject: [PATCH] shutdown: terminate subprocesses * We use a subprocess pool for running backgorund commands (e.g. `cylc clean`). * This creates subprocesses to run our commands in, however, it does not kill the subprocess once the command has completed, it keeps the subprocess open for future reuse (more efficient than creating and destroying them every time). * On shutdown we need to close the pool to mop up these subprocesses (this doesn't happen automatically). --- changes.d/619.fix.md | 1 + cylc/uiserver/app.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changes.d/619.fix.md diff --git a/changes.d/619.fix.md b/changes.d/619.fix.md new file mode 100644 index 00000000..4b67746c --- /dev/null +++ b/changes.d/619.fix.md @@ -0,0 +1 @@ +Ensure that subprocesses created by Cylc UI Server are cleaned up correctly when the server shuts down. diff --git a/cylc/uiserver/app.py b/cylc/uiserver/app.py index c4caae78..3e41dc60 100644 --- a/cylc/uiserver/app.py +++ b/cylc/uiserver/app.py @@ -580,10 +580,17 @@ def launch_instance(cls, argv=None, workflow_id=None, **kwargs): async def stop_extension(self): # stop the async scan task await self.workflows_mgr.stop() + + # stop active subscriptions for sub in self.data_store_mgr.w_subs.values(): sub.stop() - # Shutdown the thread pool executor + + # Shutdown the thread pool executor (used for subscription processing) self.data_store_mgr.executor.shutdown(wait=False) + + # stop the process pool (used for background commands) + self.executor.shutdown() + # Destroy ZeroMQ context of all sockets self.workflows_mgr.context.destroy() self.profiler.stop()