Skip to content

Commit

Permalink
shutdown: terminate subprocesses
Browse files Browse the repository at this point in the history
* 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).
  • Loading branch information
oliver-sanders committed Oct 15, 2024
1 parent 0b9f11d commit a75fdb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes.d/619.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure that subprocesses created by Cylc UI Server are cleaned up correctly when the server shuts down.
9 changes: 8 additions & 1 deletion cylc/uiserver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit a75fdb4

Please sign in to comment.