mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	asyncio, Tulip issue 139: Improve error messages on "fatal errors"
Mention if the error was caused by a read or a write, and be more specific on the object (ex: "pipe transport" instead of "transport").
This commit is contained in:
		
							parent
							
								
									c098241342
								
							
						
					
					
						commit
						065ca25aae
					
				
					 6 changed files with 64 additions and 38 deletions
				
			
		|  | @ -271,7 +271,7 @@ def _read_ready(self): | |||
|         except (BlockingIOError, InterruptedError): | ||||
|             pass | ||||
|         except OSError as exc: | ||||
|             self._fatal_error(exc) | ||||
|             self._fatal_error(exc, 'Fatal read error on pipe transport') | ||||
|         else: | ||||
|             if data: | ||||
|                 self._protocol.data_received(data) | ||||
|  | @ -291,11 +291,11 @@ def close(self): | |||
|         if not self._closing: | ||||
|             self._close(None) | ||||
| 
 | ||||
|     def _fatal_error(self, exc): | ||||
|     def _fatal_error(self, exc, message='Fatal error on pipe transport'): | ||||
|         # should be called by exception handler only | ||||
|         if not (isinstance(exc, OSError) and exc.errno == errno.EIO): | ||||
|             self._loop.call_exception_handler({ | ||||
|                 'message': 'Fatal transport error', | ||||
|                 'message': message, | ||||
|                 'exception': exc, | ||||
|                 'transport': self, | ||||
|                 'protocol': self._protocol, | ||||
|  | @ -381,7 +381,7 @@ def write(self, data): | |||
|                 n = 0 | ||||
|             except Exception as exc: | ||||
|                 self._conn_lost += 1 | ||||
|                 self._fatal_error(exc) | ||||
|                 self._fatal_error(exc, 'Fatal write error on pipe transport') | ||||
|                 return | ||||
|             if n == len(data): | ||||
|                 return | ||||
|  | @ -406,7 +406,7 @@ def _write_ready(self): | |||
|             # Remove writer here, _fatal_error() doesn't it | ||||
|             # because _buffer is empty. | ||||
|             self._loop.remove_writer(self._fileno) | ||||
|             self._fatal_error(exc) | ||||
|             self._fatal_error(exc, 'Fatal write error on pipe transport') | ||||
|         else: | ||||
|             if n == len(data): | ||||
|                 self._loop.remove_writer(self._fileno) | ||||
|  | @ -443,11 +443,11 @@ def close(self): | |||
|     def abort(self): | ||||
|         self._close(None) | ||||
| 
 | ||||
|     def _fatal_error(self, exc): | ||||
|     def _fatal_error(self, exc, message='Fatal error on pipe transport'): | ||||
|         # should be called by exception handler only | ||||
|         if not isinstance(exc, (BrokenPipeError, ConnectionResetError)): | ||||
|             self._loop.call_exception_handler({ | ||||
|                 'message': 'Fatal transport error', | ||||
|                 'message': message, | ||||
|                 'exception': exc, | ||||
|                 'transport': self, | ||||
|                 'protocol': self._protocol, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner