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
34+
2835
2936class _Clear :
3037 def clear (self ):
@@ -445,8 +452,8 @@ def _handle_sig(self, sig, _):
445452 def add_signal_handler (self , sig , callback , * args ):
446453 """asyncio's method to add a signal handler.
447454 """
448- self ._check_signal (sig )
449455 self ._check_closed ()
456+ self ._check_signal (sig )
450457 if sig == signal .SIGKILL :
451458 raise RuntimeError ("SIGKILL cannot be caught" )
452459 h = Handle (callback , args , self , context = None , is_sync = True )
@@ -458,7 +465,7 @@ def add_signal_handler(self, sig, callback, *args):
458465 def remove_signal_handler (self , sig ):
459466 """asyncio's method to remove a signal handler.
460467 """
461- self ._check_signal (sig )
468+ # self._check_signal(sig)
462469 try :
463470 h = self ._signal_handlers .pop (sig )
464471 except KeyError :
@@ -516,7 +523,7 @@ async def _reader_loop(self, fd, handle, task_status=trio.TASK_STATUS_IGNORED):
516523 handle ._scope = scope
517524 try :
518525 while not handle ._cancelled : # pragma: no branch
519- await trio . hazmat . wait_readable (fd )
526+ await _wait_readable (fd )
520527 handle ._call_sync ()
521528 await self .synchronize ()
522529 except Exception as exc :
@@ -570,7 +577,7 @@ async def _writer_loop(self, fd, handle, task_status=trio.TASK_STATUS_IGNORED):
570577 task_status .started ()
571578 try :
572579 while not handle ._cancelled : # pragma: no branch
573- await trio . hazmat . wait_writable (fd )
580+ await _wait_writable (fd )
574581 handle ._call_sync ()
575582 await self .synchronize ()
576583 except Exception as exc :
0 commit comments