diff options
author | Vitor Pereira <vmsousapereira@gmail.com> | 2017-07-18 15:34:23 (GMT) |
---|---|---|
committer | Antoine Pitrou <pitrou@free.fr> | 2017-07-18 15:34:23 (GMT) |
commit | ba75af713078966cc594fc7f0809ed53c532c58f (patch) | |
tree | d55ae73192947f840b4e28457fec3d7fc32f875e /Lib/multiprocessing/popen_fork.py | |
parent | f474c5a3f3c1fbc0383800b88e8518d43a52d1d1 (diff) | |
download | cpython-ba75af713078966cc594fc7f0809ed53c532c58f.zip cpython-ba75af713078966cc594fc7f0809ed53c532c58f.tar.gz cpython-ba75af713078966cc594fc7f0809ed53c532c58f.tar.bz2 |
bpo-30794: added kill() method to multiprocessing.Process (#2528)
* bpo-30794: added kill() method to multiprocessing.Process
* Added entries to documentation and NEWS
* Refactored test_terminate and test_kill
* Fix SIGTERM and SIGKILL being used on Windows for the tests
* Added "versionadded" marker to the documentation
* Fix trailing whitespace in doc
Diffstat (limited to 'Lib/multiprocessing/popen_fork.py')
-rw-r--r-- | Lib/multiprocessing/popen_fork.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/multiprocessing/popen_fork.py b/Lib/multiprocessing/popen_fork.py index 5af9d91..44ce9a9 100644 --- a/Lib/multiprocessing/popen_fork.py +++ b/Lib/multiprocessing/popen_fork.py @@ -49,16 +49,22 @@ class Popen(object): return self.poll(os.WNOHANG if timeout == 0.0 else 0) return self.returncode - def terminate(self): + def _send_signal(self, sig): if self.returncode is None: try: - os.kill(self.pid, signal.SIGTERM) + os.kill(self.pid, sig) except ProcessLookupError: pass except OSError: if self.wait(timeout=0.1) is None: raise + def terminate(self): + self._send_signal(signal.SIGTERM) + + def kill(self): + self._send_signal(signal.SIGKILL) + def _launch(self, process_obj): code = 1 parent_r, child_w = os.pipe() |