@@ -180,38 +180,6 @@ cdef class WSUpgradeResponseWithListener:
180180 self .listener = listener
181181
182182
183- cdef _raise_from_errno(int ec):
184- cdef str reason = strerror(ec).decode()
185-
186- exc = OSError
187-
188- if ec in (errno.EACCES, errno.EPERM):
189- exc = PermissionError
190- elif ec in (errno.EAGAIN, errno.EALREADY, EWOULDBLOCK):
191- exc = BlockingIOError
192- elif ec in (errno.EPIPE, ESHUTDOWN):
193- exc = BrokenPipeError
194- elif ec == errno.ECONNABORTED:
195- exc = ConnectionAbortedError
196- elif ec == errno.ECONNREFUSED:
197- exc = ConnectionRefusedError
198- elif ec == errno.ECONNRESET:
199- exc = ConnectionResetError
200- elif ec == errno.EEXIST:
201- exc = FileExistsError
202- elif ec == errno.ENOENT:
203- exc = FileNotFoundError
204- elif ec == errno.EINTR:
205- exc = InterruptedError
206- elif ec == errno.EISDIR:
207- exc = IsADirectoryError
208- elif ec == errno.ESRCH:
209- exc = ProcessLookupError
210- elif ec == errno.ETIMEDOUT:
211- exc = TimeoutError
212- raise exc(ec, reason)
213-
214-
215183cdef void _mask_payload(uint8_t* input , Py_ssize_t input_len, uint32_t mask) noexcept:
216184 # According to perf, _mask_payload is very fast and is not worth spending
217185 # any time optimizing it further.
@@ -860,12 +828,9 @@ cdef class WSTransport:
860828 self .underlying_transport.write(PyBytes_FromStringAndSize(< char * > ptr + bytes_written, sz - bytes_written))
861829 return
862830
863- cdef int ec = picows_get_errno()
864- if ec == errno.EAGAIN or ec == EWOULDBLOCK:
865- self .underlying_transport.write(PyBytes_FromStringAndSize(< char * > ptr, sz))
866- return
867-
868- _raise_from_errno(ec)
831+ # In case of errors we ask asyncio to try sending again.
832+ # Asyncio will try and based on error code may report 'disconnected' event.
833+ self .underlying_transport.write(PyBytes_FromStringAndSize(< char * > ptr, sz))
869834
870835
871836cdef class WSProtocol:
0 commit comments