We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a592104 commit 6e73143Copy full SHA for 6e73143
1 file changed
py/stream.c
@@ -119,6 +119,15 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
119
while (true) {
120
machine_int_t out_sz = o->type->stream_p->read(self_in, p, current_read, &error);
121
if (out_sz == -1) {
122
+ if (is_nonblocking_error(error)) {
123
+ // With non-blocking streams, we read as much as we can.
124
+ // If we read nothing, return None, just like read().
125
+ // Otherwise, return data read so far.
126
+ if (total_size == 0) {
127
+ return mp_const_none;
128
+ }
129
+ break;
130
131
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error));
132
}
133
if (out_sz == 0) {
0 commit comments