Detect OSError errno EBADF and re-raise as trio.BrokenResourceError on EventFD reads
							parent
							
								
									a553446619
								
							
						
					
					
						commit
						7766caf623
					
				|  | @ -163,10 +163,17 @@ class EventFD: | ||||||
|         async with self._read_lock: |         async with self._read_lock: | ||||||
|             self._cscope = trio.CancelScope() |             self._cscope = trio.CancelScope() | ||||||
|             with self._cscope: |             with self._cscope: | ||||||
|                 return await trio.to_thread.run_sync( |                 try: | ||||||
|                     read_eventfd, self._fd, |                     return await trio.to_thread.run_sync( | ||||||
|                     abandon_on_cancel=True |                         read_eventfd, self._fd, | ||||||
|                 ) |                         abandon_on_cancel=True | ||||||
|  |                     ) | ||||||
|  | 
 | ||||||
|  |                 except OSError as e: | ||||||
|  |                     if e.errno != errno.EBADF: | ||||||
|  |                         raise | ||||||
|  | 
 | ||||||
|  |                     raise trio.BrokenResourceError | ||||||
| 
 | 
 | ||||||
|             if self._cscope.cancelled_caught: |             if self._cscope.cancelled_caught: | ||||||
|                 raise EFDReadCancelled |                 raise EFDReadCancelled | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue