File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -158,18 +158,11 @@ cdef class UVStream(UVBaseTransport):
158
158
self .__reading_stopped()
159
159
160
160
cdef inline _try_write(self , object data):
161
- if self ._get_write_buffer_size():
162
- # Don't try to write anything as we already have some
163
- # data in the write buffers.
164
- return
165
-
166
161
cdef:
167
162
ssize_t written
168
163
int fd
169
164
Py_buffer py_buf
170
165
171
- # Let's try to send the data right away.
172
-
173
166
fd = self ._fileno()
174
167
PyObject_GetBuffer(data, & py_buf, PyBUF_SIMPLE)
175
168
written = system.send(fd, < char * > py_buf.buf, py_buf.len, 0 )
@@ -185,21 +178,27 @@ cdef class UVStream(UVBaseTransport):
185
178
exc = convert_error(- errno.errno)
186
179
self ._fatal_error(exc, True )
187
180
181
+ IF DEBUG:
182
+ if written > 0 :
183
+ self ._loop._debug_stream_write_tries += 1
184
+
188
185
return written
189
186
190
187
cdef inline _write(self , object data):
191
188
cdef:
192
189
int err
193
- int sent
194
190
_StreamWriteContext ctx
195
191
196
192
self ._ensure_alive()
197
193
198
- sent = self ._try_write(data)
199
- if sent > 0 :
200
- if sent == len (data):
201
- return
202
- data = data[sent:]
194
+ if not self ._get_write_buffer_size():
195
+ # Try to write without polling only when there is
196
+ # no data in write buffers.
197
+ sent = self ._try_write(data)
198
+ if sent > 0 :
199
+ if sent == len (data):
200
+ return
201
+ data = data[sent:]
203
202
204
203
ctx = _StreamWriteContext.new(self , data)
205
204
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ cdef class Loop:
97
97
readonly uint64_t _debug_stream_read_eof_cb_errors_total
98
98
readonly uint64_t _debug_stream_read_errors_total
99
99
100
+ readonly uint64_t _debug_stream_write_tries
100
101
readonly uint64_t _debug_stream_write_errors_total
101
102
readonly uint64_t _debug_stream_write_ctx_total
102
103
readonly uint64_t _debug_stream_write_ctx_cnt
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ cdef class Loop:
97
97
self ._debug_stream_shutdown_errors_total = 0
98
98
self ._debug_stream_listen_errors_total = 0
99
99
100
+ self ._debug_stream_write_tries = 0
100
101
self ._debug_stream_write_errors_total = 0
101
102
self ._debug_stream_write_ctx_total = 0
102
103
self ._debug_stream_write_ctx_cnt = 0
@@ -759,6 +760,8 @@ cdef class Loop:
759
760
print (' --- Streams debug info: ---' )
760
761
print (' Write errors: {}' .format(
761
762
self ._debug_stream_write_errors_total))
763
+ print (' Write without poll: {}' .format(
764
+ self ._debug_stream_write_tries))
762
765
print (' Write contexts: {: <8} | {}' .format(
763
766
self ._debug_stream_write_ctx_cnt,
764
767
self ._debug_stream_write_ctx_total))
You can’t perform that action at this time.
0 commit comments