mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	bpo-31019: Fix multiprocessing.Process.is_alive() (#2875)
multiprocessing.Process.is_alive() now removes the process from the _children set if the process completed. The change prevents leaking "dangling" processes.
This commit is contained in:
		
							parent
							
								
									627d2c8e8d
								
							
						
					
					
						commit
						2db64823c2
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		|  | @ -148,10 +148,16 @@ def is_alive(self): | ||||||
|         if self is _current_process: |         if self is _current_process: | ||||||
|             return True |             return True | ||||||
|         assert self._parent_pid == os.getpid(), 'can only test a child process' |         assert self._parent_pid == os.getpid(), 'can only test a child process' | ||||||
|  | 
 | ||||||
|         if self._popen is None: |         if self._popen is None: | ||||||
|             return False |             return False | ||||||
|         self._popen.poll() | 
 | ||||||
|         return self._popen.returncode is None |         returncode = self._popen.poll() | ||||||
|  |         if returncode is None: | ||||||
|  |             return True | ||||||
|  |         else: | ||||||
|  |             _children.discard(self) | ||||||
|  |             return False | ||||||
| 
 | 
 | ||||||
|     def close(self): |     def close(self): | ||||||
|         ''' |         ''' | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner