File tree 2 files changed +12
-2
lines changed
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:
368
368
return b""
369
369
370
370
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" )
373
375
374
376
# We could compile all the chunks here instead of just returning
375
377
# 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:
87
87
assert stream .read () == b""
88
88
89
89
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
+
90
98
def test_stream_read1 () -> None :
91
99
stream = BufferableByteStream ()
92
100
stream .write (b"foo" )
You can’t perform that action at this time.
0 commit comments