diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 5050a21..1e5478b 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -122,10 +122,12 @@ class SFTPFile (BufferedFile): in the buffer, return None. otherwise, behaves like a normal read. """ # while not closed, and haven't fetched past the current position, and haven't reached EOF... - while not self._prefetch_done and not self._closed: + while True: offset = self._data_in_prefetch_buffers(self._realpos) if offset is not None: break + if self._prefetch_done or self._closed: + break self.sftp._read_response() self._check_exception() if offset is None: