Merge lp:~asac/lava-dispatcher/send-signal-for-fastmodel-shutdown into lp:lava-dispatcher

Proposed by Alexander Sack
Status: Rejected
Rejected by: Neil Williams
Proposed branch: lp:~asac/lava-dispatcher/send-signal-for-fastmodel-shutdown
Merge into: lp:lava-dispatcher
Diff against target: 53 lines (+31/-5)
1 file modified
lava_dispatcher/client/fastmodel.py (+31/-5)
To merge this branch: bzr merge lp:~asac/lava-dispatcher/send-signal-for-fastmodel-shutdown
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+120375@code.launchpad.net

Description of the change

I sometimes overserved problems of fast models not shutting down when using the "pexpect.close(...)" feature.

This change uses SIGINT and SIGKILL to shut down RTSM; the draining thread for the fastmodel process will die automatically once RTSM process closes its IO.

To post a comment you must log in.

Unmerged revisions

373. By Alexander Sack

implement killing RTSM process gracefully from mainthread by sending SIGINT and SIGKILL

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava_dispatcher/client/fastmodel.py'
--- lava_dispatcher/client/fastmodel.py 2012-08-10 15:25:36 +0000
+++ lava_dispatcher/client/fastmodel.py 2012-08-20 12:23:01 +0000
@@ -29,6 +29,8 @@
29import stat29import stat
30import threading30import threading
31import time31import time
32import sys
33import signal
3234
33from lava_dispatcher.client.base import (35from lava_dispatcher.client.base import (
34 CommandRunner,36 CommandRunner,
@@ -215,11 +217,35 @@
215 self._sim_binary, self._axf, self._sd_image, options)217 self._sim_binary, self._axf, self._sd_image, options)
216218
217 def _stop(self):219 def _stop(self):
218 if self.proc is not None:220 if self._sim_proc is None or self.proc is None:
219 self.proc.close()221 return
220 if self._sim_proc is not None:222 __pid = self._sim_proc.pid
221 self._sim_proc.close()223 try:
222224 os.kill (__pid, signal.SIGINT)
225 except:
226 logging.info ("Error terminating process: %s", sys.exc_info())
227 for i in range(30):
228 time.sleep(2)
229 try:
230 os.kill(__pid, 0)
231 logging.info ("FastModel pid(%d) still needs to shutdown..." % __pid)
232 except:
233 logging.info ("FastModel done!")
234 return
235 logging.warn ("FastModel failed to shut down ... continuing anyway!")
236
237 try:
238 logging.warn ("FastModel failed to shut down ... giving up; sending SIGKILL!")
239 os.kill (__pid, signal.SIGKILL)
240 except:
241 logging.info ("Error killing process: %s", sys.exc_info())
242
243 try:
244 self.proc.close(True)
245 except:
246 logging.info ("Error closing telnet session: %s", sys.exc_info())
247
248
223 def _drain_sim_proc(self):249 def _drain_sim_proc(self):
224 '''pexpect will continue to get data for the simproc process. We need250 '''pexpect will continue to get data for the simproc process. We need
225 to keep this pipe drained so that it won't get full and then stop block251 to keep this pipe drained so that it won't get full and then stop block

Subscribers

People subscribed via source and target branches