Skip to content

Commit d562031

Browse files
committed
Handle 'No such process' exception
`send_signal()`, `terminate()` or `kill()` methods of a subprocess.Popen object raise OSError on Python 2, when the process does not exist and Python knows about it. See: | >>> import subprocess | >>> p = subprocess.Popen(['true']) | >>> p.poll() | 0 | >>> p.kill() | Traceback (most recent call last): | File "<stdin>", line 1, in <module> | File "/usr/lib64/python2.7/subprocess.py", line 1279, in kill | self.send_signal(signal.SIGKILL) | File "/usr/lib64/python2.7/subprocess.py", line 1269, in send_signal | os.kill(self.pid, sig) | OSError: [Errno 3] No such process Python 3 does not raise the exception in the case. Let's protect ourself from possible races / behaviour differences and silence the exception. Part of #157
1 parent 318ffa2 commit d562031

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/tarantool_server.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,10 @@ def kill():
10481048
'Sending SIGKILL...'.format(
10491049
self.name, timeout, signal, signame(signal),
10501050
format_process(self.process.pid)))
1051-
self.process.kill()
1051+
try:
1052+
self.process.kill()
1053+
except OSError:
1054+
pass
10521055

10531056
timer = Timer(timeout, kill)
10541057
timer.start()

0 commit comments

Comments
 (0)