You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
use SFTPClient's get method to download big file from sftp server will block #1779
Use SFTPClient's get method to download big file from sftp server will block. The error stack information as below: sftp_download_error_stack_20201118.txt
I found the problem is here:
python3.6\Lib\site-packages\paramiko\sftp_file.py
def _prefetch_thread(self, chunks):
# do these read requests in a temporary thread because there may be
# a lot of them, so it may block.
for offset, length in chunks:
num = self.sftp._async_request(
self, CMD_READ, self.handle, long(offset), int(length)
)
with self._prefetch_lock:
self._prefetch_extents[num] = (offset, length)
too many requests at same time. And my solution as below:
python3.6\Lib\site-packages\paramiko\sftp_file.py
def _prefetch_thread(self, chunks):
# do these read requests in a temporary thread because there may be
# a lot of them, so it may block.
max_request_num = 512
to_wait = False
for offset, length in chunks:
num = self.sftp._async_request(
self, CMD_READ, self.handle, long(offset), int(length)
)
with self._prefetch_lock:
self._prefetch_extents[num] = (offset, length)
if len(self._prefetch_extents) >= max_request_num:
to_wait = True
if to_wait:
time.sleep(1)
to_wait = False
I hope the official version can fix the problem with an appropriate concurrency number limit and this number is configurable. Or use a better solution to solve the problem. Thank you!
Activity
bitprophet commentedon Jun 9, 2023
Rolling into #2058 - thanks!