summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r--Lib/multiprocessing/popen_fork.py10
-rw-r--r--Lib/multiprocessing/popen_spawn_win32.py2
-rw-r--r--Lib/multiprocessing/process.py7
3 files changed, 17 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()
diff --git a/Lib/multiprocessing/popen_spawn_win32.py b/Lib/multiprocessing/popen_spawn_win32.py
index ecb86e9..3e42e9c 100644
--- a/Lib/multiprocessing/popen_spawn_win32.py
+++ b/Lib/multiprocessing/popen_spawn_win32.py
@@ -97,5 +97,7 @@ class Popen(object):
if self.wait(timeout=1.0) is None:
raise
+ kill = terminate
+
def close(self):
self.finalizer()
diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py
index fde97b7..ce4ce43 100644
--- a/Lib/multiprocessing/process.py
+++ b/Lib/multiprocessing/process.py
@@ -122,6 +122,13 @@ class BaseProcess(object):
self._check_closed()
self._popen.terminate()
+ def kill(self):
+ '''
+ Terminate process; sends SIGKILL signal or uses TerminateProcess()
+ '''
+ self._check_closed()
+ self._popen.kill()
+
def join(self, timeout=None):
'''
Wait until child process terminates