Skip to content

Commit

Permalink
Merge pull request #3302 from radical-cybertools/fix/process_cleanup
Browse files Browse the repository at this point in the history
ensure scheduler sub-process terminates
  • Loading branch information
andre-merzky authored Jan 24, 2025
2 parents c363510 + 5919c53 commit 7471bef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/radical/pilot/agent/scheduler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__copyright__ = 'Copyright 2013-2022, The RADICAL-Cybertools Team'
__license__ = 'MIT'

import os
import copy
import time
import queue
Expand Down Expand Up @@ -272,6 +273,10 @@ def initialize(self):
self._p.daemon = True
self._p.start()

self._pwatcher = ru.PWatcher(uid='%s.pw' % self._uid, log=self._log)
self._pwatcher.watch(os.getpid())
self._pwatcher.watch(self._p.pid)


# --------------------------------------------------------------------------
#
Expand Down Expand Up @@ -619,6 +624,10 @@ def _schedule_tasks(self):

self._scheduler_process = True

self._pwatcher = ru.PWatcher(uid='%s.pw' % self._uid, log=self._log)
self._pwatcher.watch(os.getpid())
self._pwatcher.watch(os.getppid())

# ZMQ endpoints will not have survived the fork. Specifically the
# registry client of the component base class will have to reconnect.
# Note that `self._reg` of the base class is a *pointer* to the sesison
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/test_scheduler/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def _mock_schedule_tasks(*args, **kwargs):
sched.nodes = []
sched._partitions = {}
sched._scheduler_process = False
sched._uid = 'uid'

sched._session = mock.Mock()

Expand Down

0 comments on commit 7471bef

Please sign in to comment.