File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -274,12 +274,21 @@ pub(super) mod _os {
274274 }
275275
276276 #[ pyfunction]
277- fn read ( fd : crt_fd:: Borrowed < ' _ > , n : usize , vm : & VirtualMachine ) -> io :: Result < PyBytesRef > {
277+ fn read ( fd : crt_fd:: Borrowed < ' _ > , n : usize , vm : & VirtualMachine ) -> PyResult < PyBytesRef > {
278278 let mut buffer = vec ! [ 0u8 ; n] ;
279- let n = crt_fd:: read ( fd, & mut buffer) ?;
280- buffer. truncate ( n) ;
281-
282- Ok ( vm. ctx . new_bytes ( buffer) )
279+ loop {
280+ match crt_fd:: read ( fd, & mut buffer) {
281+ Ok ( n) => {
282+ buffer. truncate ( n) ;
283+ return Ok ( vm. ctx . new_bytes ( buffer) ) ;
284+ }
285+ Err ( e) if e. raw_os_error ( ) == Some ( libc:: EINTR ) => {
286+ vm. check_signals ( ) ?;
287+ continue ;
288+ }
289+ Err ( e) => return Err ( e. into_pyexception ( vm) ) ,
290+ }
291+ }
283292 }
284293
285294 #[ pyfunction]
You can’t perform that action at this time.
0 commit comments