Detect OSError errno EBADF and re-raise as trio.BrokenResourceError on EventFD reads
parent
a553446619
commit
7766caf623
|
@ -163,11 +163,18 @@ class EventFD:
|
|||
async with self._read_lock:
|
||||
self._cscope = trio.CancelScope()
|
||||
with self._cscope:
|
||||
try:
|
||||
return await trio.to_thread.run_sync(
|
||||
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:
|
||||
raise EFDReadCancelled
|
||||
|
||||
|
|
Loading…
Reference in New Issue