Skip to content

Commit 670f08e

Browse files
committed
catch exception from .fileno()
1 parent 1cee706 commit 670f08e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/zmq_anyio/_socket.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,12 +898,18 @@ async def wait_or_cancel() -> None:
898898
await self.stopped.wait()
899899
tg.cancel_scope.cancel()
900900

901+
def fileno() -> int:
902+
try:
903+
return self._shadow_sock.fileno()
904+
except zmq.ZMQError:
905+
return -1
906+
901907
try:
902-
while not self.closed:
908+
while (fd := fileno()) > 0:
903909
async with create_task_group() as tg:
904910
tg.start_soon(wait_or_cancel)
905911
try:
906-
await wait_readable(self._shadow_sock)
912+
await wait_readable(fd)
907913
except ClosedResourceError:
908914
break
909915
tg.cancel_scope.cancel()

0 commit comments

Comments
 (0)