Skip to content

Commit b520fb1

Browse files
committed
use wait_socket_read/writable on Windows
1 parent 3deb436 commit b520fb1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

trio_asyncio/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525

2626
_mswindows = (sys.platform == "win32")
2727

28+
try:
29+
_wait_readable = trio.hazmat.wait_readable
30+
_wait_writable = trio.hazmat.wait_writable
31+
except AttributeError:
32+
_wait_readable = trio.hazmat.wait_socket_readable
33+
_wait_writable = trio.hazmat.wait_socket_writable
2834

2935
class _Clear:
3036
def clear(self):
@@ -516,7 +522,7 @@ async def _reader_loop(self, fd, handle, task_status=trio.TASK_STATUS_IGNORED):
516522
handle._scope = scope
517523
try:
518524
while not handle._cancelled: # pragma: no branch
519-
await trio.hazmat.wait_readable(fd)
525+
await _wait_readable(fd)
520526
handle._call_sync()
521527
await self.synchronize()
522528
except Exception as exc:
@@ -570,7 +576,7 @@ async def _writer_loop(self, fd, handle, task_status=trio.TASK_STATUS_IGNORED):
570576
task_status.started()
571577
try:
572578
while not handle._cancelled: # pragma: no branch
573-
await trio.hazmat.wait_writable(fd)
579+
await _wait_writable(fd)
574580
handle._call_sync()
575581
await self.synchronize()
576582
except Exception as exc:

0 commit comments

Comments
 (0)