File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -368,8 +368,10 @@ def read(self, size: int | None = -1) -> bytes:
368368 return b""
369369
370370 if len (self ._chunks ) == 0 :
371- # When the CRT recieves this, it'll try again later.
372- raise BlockingIOError ("read" )
371+ if self ._done :
372+ return b""
373+ else :
374+ raise BlockingIOError ("read" )
373375
374376 # We could compile all the chunks here instead of just returning
375377 # the one, BUT the CRT will keep calling read until empty bytes
Original file line number Diff line number Diff line change @@ -87,6 +87,14 @@ def test_closed_stream_read() -> None:
8787 assert stream .read () == b""
8888
8989
90+ def test_done_stream_read () -> None :
91+ stream = BufferableByteStream ()
92+ stream .write (b"foo" )
93+ stream .end_stream ()
94+ assert stream .read () == b"foo"
95+ assert stream .read () == b""
96+
97+
9098def test_stream_read1 () -> None :
9199 stream = BufferableByteStream ()
92100 stream .write (b"foo" )
You can’t perform that action at this time.
0 commit comments