Skip to content

Commit

Permalink
Send a SIGKILL if agent timesout instead of SIGINT
Browse files Browse the repository at this point in the history
This better handles the case of agents that run into errors on shutdown and
hang.
  • Loading branch information
BrianJKoopman committed Aug 28, 2024
1 parent dc886b4 commit 5dd79e2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ocs/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(self, timeout):
This runs the agent subprocess defined by ``self.cmd``. Output is
written to a ``PIPE``. If the agent does not exit within the given
timeout it will be interruptd with a ``SIGINT``.
timeout it will be interrupted with a ``SIGKILL``.
Parameters:
timeout (float): Timeout in seconds to wait for agent to exit.
Expand All @@ -77,7 +77,8 @@ def run(self, timeout):
self._raise_subprocess(f"Agent failed to startup, cmd: {self.cmd}")

def _interrupt(self):
self.proc.send_signal(signal.SIGINT)
# not graceful, but handles really misbehaved agent subprocesses
self.proc.send_signal(signal.SIGKILL)
self._timedout = True

def _raise_subprocess(self, msg):
Expand All @@ -93,7 +94,7 @@ def shutdown(self):
and an exception raised.
"""
# avoid sending SIGINT twice
# don't send SIGINT if we've already sent SIGKILL
if not self._timedout:
self.proc.send_signal(signal.SIGINT)
self._timer.cancel()
Expand Down

0 comments on commit 5dd79e2

Please sign in to comment.