File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -680,6 +680,48 @@ cdef class UVStream(UVBaseTransport):
680
680
if self ._conn_lost:
681
681
self ._conn_lost += 1
682
682
return
683
+
684
+ cdef int sent
685
+
686
+ if (self ._buffer_size == 0 and
687
+ (< uv.uv_stream_t* > self ._handle).write_queue_size == 0 ):
688
+
689
+ sent_ = self ._try_write(buf)
690
+
691
+ if sent_ is None :
692
+ # A `self._fatal_error` was called.
693
+ # It might not raise an exception under some
694
+ # conditions.
695
+ if not self ._closing:
696
+ raise RuntimeError (' stream is open after '
697
+ ' UVStream._try_write returned None' )
698
+
699
+ return
700
+
701
+ sent = sent_
702
+
703
+ if sent == 0 :
704
+ # All data was successfully written.
705
+ # on_write will call "maybe_resume_protocol".
706
+ self ._on_write()
707
+ return
708
+
709
+ if sent > 0 :
710
+ if UVLOOP_DEBUG:
711
+ if sent == len (buf):
712
+ raise RuntimeError (' _try_write sent all data and '
713
+ ' returned non-zero' )
714
+
715
+ if PyBytes_CheckExact(buf):
716
+ # Cast bytes to memoryview to avoid copying
717
+ # data that wasn't sent.
718
+ buf = memoryview(buf)
719
+ buf = buf[sent:]
720
+
721
+ # At this point it's either data was sent partially,
722
+ # or an EAGAIN has happened.
723
+ # buffer remaining data and send it later
724
+
683
725
self ._buffer_write(buf)
684
726
self ._initiate_write()
685
727
You can’t perform that action at this time.
0 commit comments