mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Issue #22922: Fix ProactorEventLoop.close()
Close the IocpProactor before closing the event loop. IocpProactor.close() can call loop.call_soon(), which is forbidden when the event loop is closed.
This commit is contained in:
		
							parent
							
								
									82f34ada45
								
							
						
					
					
						commit
						b86a96802b
					
				
					 1 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -387,13 +387,19 @@ def close(self):
 | 
			
		|||
            raise RuntimeError("Cannot close a running event loop")
 | 
			
		||||
        if self.is_closed():
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        # Call these methods before closing the event loop (before calling
 | 
			
		||||
        # BaseEventLoop.close), because they can schedule callbacks with
 | 
			
		||||
        # call_soon(), which is forbidden when the event loop is closed.
 | 
			
		||||
        self._stop_accept_futures()
 | 
			
		||||
        self._close_self_pipe()
 | 
			
		||||
        super().close()
 | 
			
		||||
        self._proactor.close()
 | 
			
		||||
        self._proactor = None
 | 
			
		||||
        self._selector = None
 | 
			
		||||
 | 
			
		||||
        # Close the event loop
 | 
			
		||||
        super().close()
 | 
			
		||||
 | 
			
		||||
    def sock_recv(self, sock, n):
 | 
			
		||||
        return self._proactor.recv(sock, n)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue