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
1=== modified file 'lava_dispatcher/client/fastmodel.py'
2--- lava_dispatcher/client/fastmodel.py 2012-08-10 15:25:36 +0000
3+++ lava_dispatcher/client/fastmodel.py 2012-08-20 12:23:01 +0000
4@@ -29,6 +29,8 @@
5 import stat
6 import threading
7 import time
8+import sys
9+import signal
10
11 from lava_dispatcher.client.base import (
12 CommandRunner,
13@@ -215,11 +217,35 @@
14 self._sim_binary, self._axf, self._sd_image, options)
15
16 def _stop(self):
17- if self.proc is not None:
18- self.proc.close()
19- if self._sim_proc is not None:
20- self._sim_proc.close()
21-
22+ if self._sim_proc is None or self.proc is None:
23+ return
24+ __pid = self._sim_proc.pid
25+ try:
26+ os.kill (__pid, signal.SIGINT)
27+ except:
28+ logging.info ("Error terminating process: %s", sys.exc_info())
29+ for i in range(30):
30+ time.sleep(2)
31+ try:
32+ os.kill(__pid, 0)
33+ logging.info ("FastModel pid(%d) still needs to shutdown..." % __pid)
34+ except:
35+ logging.info ("FastModel done!")
36+ return
37+ logging.warn ("FastModel failed to shut down ... continuing anyway!")
38+
39+ try:
40+ logging.warn ("FastModel failed to shut down ... giving up; sending SIGKILL!")
41+ os.kill (__pid, signal.SIGKILL)
42+ except:
43+ logging.info ("Error killing process: %s", sys.exc_info())
44+
45+ try:
46+ self.proc.close(True)
47+ except:
48+ logging.info ("Error closing telnet session: %s", sys.exc_info())
49+
50+
51 def _drain_sim_proc(self):
52 '''pexpect will continue to get data for the simproc process. We need
53 to keep this pipe drained so that it won't get full and then stop block

Subscribers

People subscribed via source and target branches