Skip to content

Commit 0ade30d

Browse files
committed
Wrap fileno() method
1 parent 2260e0a commit 0ade30d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/zmq_anyio/_socket.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ def __init__(
194194
self._task_group = task_group
195195
self.__stack = None
196196

197+
def fileno(self) -> int:
198+
try:
199+
return super().fileno()
200+
except zmq.error.ZMQError:
201+
return -1
202+
197203
def get(self, key):
198204
result = super().get(key)
199205
if key == EVENTS:

tests/test_socket.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,12 @@ async def test_close(create_bound_pair):
341341
async with create_task_group() as tg:
342342
await tg.start(a.start)
343343
await tg.start(b.start)
344+
print(f"{a.fileno()=}")
345+
print(f"{b.fileno()=}")
344346
a.close()
345347
b.close()
348+
print(f"{a.fileno()=}")
349+
print(f"{b.fileno()=}")
346350
await sleep(0.1)
347351

348352

0 commit comments

Comments
 (0)