mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	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
This commit is contained in:
		
							parent
							
								
									f474c5a3f3
								
							
						
					
					
						commit
						ba75af7130
					
				
					 6 changed files with 40 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -49,16 +49,22 @@ def wait(self, timeout=None):
 | 
			
		|||
            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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue