37,743
社区成员




import paramiko
import os
import os.path
username='test'
password='test'
host='192.168.1.1'
port=22
t=paramiko.Transport((host,port))
t.connect(username=username,password=password)
sftp=paramiko.SFTPClient.from_transport(t)
rpath='/test.rar'
try:
sftp.get(rpath,r'D:\TEMP\1.rar',print) #下载文件
except Exception as e:
print(e)
t.close()
threadnum = threadnum + 1
if threadnum == 100:
#print(threadnum)
threadnum=0
time.sleep(1)
修改完代码如下:
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.
threadnum=0
for offset, length in chunks:
threadnum = threadnum + 1
if threadnum == 100:
#print(threadnum)
threadnum=0
time.sleep(1)
num = self.sftp._async_request(
self,
CMD_READ,
self.handle,
long(offset),
int(length))
with self._prefetch_lock:
self._prefetch_extents[num] = (offset, length)