擅长:python、mysql、java
<p>正如老鹰所说,他们很好地打印出进展情况。但是,打印频率太高,会消耗大量的资源。在</p>
<p>要控制打印频率,我们需要重写“发送文件”或“发送文件”功能</p>
<pre><code>def _send_files(self, files):
...
buff_size = self.buff_size
chan = self.channel
# Add time control
time_cursor=datetime.datetime.now()
while file_pos < size:
chan.sendall(file_hdl.read(buff_size))
file_pos = file_hdl.tell()
now=datetime.datetime.now()
# Status check every one sec
if self._progress and (now-time_cursor).seconds>1:
self._progress(basename, size, file_pos)
time_cursor=now
chan.sendall('\x00')
file_hdl.close()
self._recv_confirm()
</code></pre>