Skip to content

Commit

Permalink
Merge pull request #1204 from MetPX/issue1203
Browse files Browse the repository at this point in the history
Change stop output to show the number of processes still running (like v2)
  • Loading branch information
petersilva authored Sep 1, 2024
2 parents 9c37250 + ce3adbd commit 7f6726b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sarracenia/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2346,16 +2346,17 @@ def stop(self):
attempts_max = 5
now = time.time()

running_pids = len(pids_signalled)
while attempts < attempts_max:
for pid in self.procs:
if (not self.procs[pid]['claimed']) and (
(now - self.procs[pid]['create_time']) > 50):
(now - self.procs[pid]['create_time']) > 50 and pid not in pids_signalled):
print( f"pid: {pid} \"{' '.join(self.procs[pid]['cmdline'])}\" does not match any configured instance, sending it TERM" )
signal_pid(pid, signal.SIGTERM)
pids_signalled |= set([pid])

ttw = 1 << attempts
print( f"Waiting {ttw} sec. to check if {len(pids_signalled)} processes stopped (try: {attempts})" )
print( f"Waiting {ttw} sec. to check if {running_pids} processes stopped (try: {attempts})" )
time.sleep(ttw)
# update to reflect killed processes.
self._read_procs()
Expand Down Expand Up @@ -2393,7 +2394,7 @@ def stop(self):
for i in self.states[c][cfg]['instance_pids']:
if self.states[c][cfg]['instance_pids'][i] in self.procs:
p=self.states[c][cfg]['instance_pids'][i]
print( f"signal_pid( {p}, SIGKILL )")
print( f"signal_pid( {p} \"{' '.join(self.procs[p]['cmdline'])}\", SIGKILL )")
signal_pid(p, signal.SIGKILL)
pids_signalled |= set([p])
print('.', end='')
Expand Down

0 comments on commit 7f6726b

Please sign in to comment.