Skip to content

Commit 82a0425

Browse files
committed
Fix unstable test on EOF.
1 parent b996e0f commit 82a0425

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

uvloop/handles/stream.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,12 @@ cdef void __uv_stream_buffered_on_read(uv.uv_stream_t* stream,
953953
return
954954

955955
try:
956-
if not sc._read_pybuf_acquired:
956+
if nread > 0 and not sc._read_pybuf_acquired:
957+
# From libuv docs:
958+
# nread is > 0 if there is data available or < 0 on error. When
959+
# we’ve reached EOF, nread will be set to UV_EOF. When
960+
# nread < 0, the buf parameter might not point to a valid
961+
# buffer; in that case buf.len and buf.base are both set to 0.
957962
raise RuntimeError(
958963
f'no python buffer is allocated in on_read; nread={nread}')
959964

0 commit comments

Comments
 (0)