scp.py
scp.py copied to clipboard
File not closed in case SocketTimeout occured
In function _recv_file(self, cmd) file where received data is stored is opened (file_hdl), but it is closed only in case whole data is transmitted properly. In case transmission is failed the file is kept open and prevents from reattempt. For example in case SocketTimeout occurred, following error is seen during reattempt: [WinError 32] The process cannot access the file because it is being used by another process:
File handler file_hdl should be closed also in case exceptions SCPException are raised in that function.