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 Aug 8, 2024
1 parent 6d95887 commit 8cb81dd
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()

Check warning on line 583 in cylc/uiserver/app.py

View check run for this annotation

Codecov / codecov/patch

cylc/uiserver/app.py#L583

Added line #L583 was not covered by tests
# 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)

Check warning on line 588 in cylc/uiserver/app.py

View check run for this annotation

Codecov / codecov/patch

cylc/uiserver/app.py#L587-L588

Added lines #L587 - L588 were not covered by tests
self.data_store_mgr.executor.shutdown(wait=False)

Check warning on line 590 in cylc/uiserver/app.py

View check run for this annotation

Codecov / codecov/patch

cylc/uiserver/app.py#L590

Added line #L590 was not covered by tests
# 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 8cb81dd

Please sign in to comment.