902 # stderr may be buffered under win32 when redirected to files, |
902 # stderr may be buffered under win32 when redirected to files, |
903 # including stdout. |
903 # including stdout. |
904 if not getattr(self.ferr, 'closed', False): |
904 if not getattr(self.ferr, 'closed', False): |
905 self.ferr.flush() |
905 self.ferr.flush() |
906 except IOError as inst: |
906 except IOError as inst: |
907 raise error.StdioError(inst) |
907 if inst.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
|
908 raise error.StdioError(inst) |
908 |
909 |
909 def flush(self): |
910 def flush(self): |
910 # opencode timeblockedsection because this is a critical path |
911 # opencode timeblockedsection because this is a critical path |
911 starttime = util.timer() |
912 starttime = util.timer() |
912 try: |
913 try: |
913 try: |
914 try: |
914 self.fout.flush() |
915 self.fout.flush() |
915 except IOError as err: |
916 except IOError as err: |
916 raise error.StdioError(err) |
917 if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
|
918 raise error.StdioError(err) |
917 finally: |
919 finally: |
918 try: |
920 try: |
919 self.ferr.flush() |
921 self.ferr.flush() |
920 except IOError as err: |
922 except IOError as err: |
921 raise error.StdioError(err) |
923 if err.errno not in (errno.EPIPE, errno.EIO, errno.EBADF): |
|
924 raise error.StdioError(err) |
922 finally: |
925 finally: |
923 self._blockedtimes['stdio_blocked'] += \ |
926 self._blockedtimes['stdio_blocked'] += \ |
924 (util.timer() - starttime) * 1000 |
927 (util.timer() - starttime) * 1000 |
925 |
928 |
926 def _isatty(self, fh): |
929 def _isatty(self, fh): |