mirror of
				https://github.com/python/cpython.git
				synced 2025-11-01 06:01:29 +00:00 
			
		
		
		
	Issue #23347, asyncio: send_signal(), terminate(), kill() don't check if the
transport was closed. The check broken a Tulip example and this limitation is arbitrary. Check if _proc is None should be enough. Enhance also close(): do nothing when called the second time.
This commit is contained in:
		
							parent
							
								
									1077dee457
								
							
						
					
					
						commit
						f2e43cbbd4
					
				
					 2 changed files with 3 additions and 20 deletions
				
			
		|  | @ -84,6 +84,8 @@ def _make_read_subprocess_pipe_proto(self, fd): | |||
|         raise NotImplementedError | ||||
| 
 | ||||
|     def close(self): | ||||
|         if self._closed: | ||||
|             return | ||||
|         self._closed = True | ||||
| 
 | ||||
|         for proto in self._pipes.values(): | ||||
|  | @ -100,8 +102,7 @@ def close(self): | |||
|             except ProcessLookupError: | ||||
|                 pass | ||||
| 
 | ||||
|             # Don't clear the _proc reference yet because _post_init() may | ||||
|             # still run | ||||
|             # Don't clear the _proc reference yet: _post_init() may still run | ||||
| 
 | ||||
|     # On Python 3.3 and older, objects with a destructor part of a reference | ||||
|     # cycle are never destroyed. It's not more the case on Python 3.4 thanks | ||||
|  | @ -125,8 +126,6 @@ def get_pipe_transport(self, fd): | |||
|             return None | ||||
| 
 | ||||
|     def _check_proc(self): | ||||
|         if self._closed: | ||||
|             raise ValueError("operation on closed transport") | ||||
|         if self._proc is None: | ||||
|             raise ProcessLookupError() | ||||
| 
 | ||||
|  |  | |||
|  | @ -47,22 +47,6 @@ def create_transport(self, waiter=None): | |||
|                         None, None, None, 0, waiter=waiter) | ||||
|         return (transport, protocol) | ||||
| 
 | ||||
|     def test_close(self): | ||||
|         waiter = asyncio.Future(loop=self.loop) | ||||
|         transport, protocol = self.create_transport(waiter) | ||||
|         transport._process_exited(0) | ||||
|         transport.close() | ||||
| 
 | ||||
|         # The loop didn't run yet | ||||
|         self.assertFalse(protocol.connection_made.called) | ||||
| 
 | ||||
|         # methods must raise ProcessLookupError if the transport was closed | ||||
|         self.assertRaises(ValueError, transport.send_signal, signal.SIGTERM) | ||||
|         self.assertRaises(ValueError, transport.terminate) | ||||
|         self.assertRaises(ValueError, transport.kill) | ||||
| 
 | ||||
|         self.loop.run_until_complete(waiter) | ||||
| 
 | ||||
|     def test_proc_exited(self): | ||||
|         waiter = asyncio.Future(loop=self.loop) | ||||
|         transport, protocol = self.create_transport(waiter) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner