Skip to content

Commit 15c8d73

Browse files
committed
stream: Optimize Transport.writelines a bit
1 parent e744e41 commit 15c8d73

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

uvloop/handles/stream.pyx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,19 @@ cdef class UVStream(UVBaseTransport):
278278
self._maybe_pause_protocol()
279279

280280
def writelines(self, bufs):
281-
self.write(b''.join(bufs))
281+
self._ensure_alive()
282+
283+
if self._eof:
284+
raise RuntimeError('Cannot call writelines() after write_eof()')
285+
if self._conn_lost:
286+
self._conn_lost += 1
287+
return
288+
289+
for buf in bufs:
290+
if buf:
291+
self._write(buf)
292+
293+
self._maybe_pause_protocol()
282294

283295
def write_eof(self):
284296
self._ensure_alive()

0 commit comments

Comments
 (0)