Skip to content

Commit

Permalink
Merge pull request #43 from srstevenson/reduce-duplication
Browse files Browse the repository at this point in the history
Reduce duplication in PtyWithClients.terminate
  • Loading branch information
takluyver authored Nov 15, 2017
2 parents 00f989a + 6ab258b commit ebac2d7
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions terminado/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,12 @@ def terminate(self, force=False):
if not self.ptyproc.isalive():
raise gen.Return(True)
try:
self.kill(signal.SIGHUP)
yield sleep()
if not self.ptyproc.isalive():
raise gen.Return(True)
self.kill(signal.SIGCONT)
yield sleep()
if not self.ptyproc.isalive():
raise gen.Return(True)
self.kill(signal.SIGINT)
yield sleep()
if not self.ptyproc.isalive():
raise gen.Return(True)
self.kill(signal.SIGTERM)
yield sleep()
if not self.ptyproc.isalive():
raise gen.Return(True)
for sig in [signal.SIGHUP, signal.SIGCONT, signal.SIGINT,
signal.SIGTERM]:
self.kill(sig)
yield sleep()
if not self.ptyproc.isalive():
raise gen.Return(True)
if force:
self.kill(signal.SIGKILL)
yield sleep()
Expand Down

0 comments on commit ebac2d7

Please sign in to comment.