Commit 4ea3e7be authored by Julien Muchembled's avatar Julien Muchembled

Do not send TERM signal to a process that has already been waited on

parent f3a69c98
...@@ -86,8 +86,8 @@ class Connection(object): ...@@ -86,8 +86,8 @@ class Connection(object):
def close(self): def close(self):
try: try:
self.process.stop() self.process.stop()
except (AttributeError, OSError): except AttributeError:
pass # we already polled an exited process pass
def refresh(self): def refresh(self):
# Check that the connection is alive # Check that the connection is alive
......
...@@ -156,10 +156,11 @@ class Popen(subprocess.Popen): ...@@ -156,10 +156,11 @@ class Popen(subprocess.Popen):
self.returncode = -1 self.returncode = -1
def stop(self): def stop(self):
if self.pid: if self.pid and self.returncode is None:
self.terminate() self.terminate()
t = threading.Timer(5, self.kill) t = threading.Timer(5, self.kill)
t.start() t.start()
# PY3: use waitid(WNOWAIT) and call self.poll() after t.cancel()
r = self.wait() r = self.wait()
t.cancel() t.cancel()
return r return r
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment