여러 세션을 동시에 사용하여 ftp 서버에서 여러 파일을 동시에 다운로드하고 있습니다. 어떤 점 하나 개의 세션 (나는 생각한다)에서 다른 프로세스에 의해 액세스되는 파일을 읽고 다음과 같은 오류가 발생합니다 :병렬 FTP 다운로드 오류 처리
Traceback (most recent call last): File
"F:\utilities\python\downloadFTP_NV.py", line 66, in <module>
os.unlink(FILE) WindowsError: [Error 32] The process cannot access the file because it is being used by another process:
u'm_4011851_ne_11_1_20100620.tif'
이 내가 처리하는 가장 좋은 방법을 찾을 수 없습니다 코드의 블록입니다 다음 파일에 오류 및 이동 다운로드 : 나는 중복 프로세스를 줄이는 데 도움이되는 time.sleep(5)
와 다른 except
문을 추가하는 방법에 대한 생각
# Set logic so that already downloaded or partially
# downloaded files will not be downloaded again
if os.path.exists(fileCheck): # "fileCheck" is a file prior to renaming
print 'File "%s" exists already' % name
pass
elif os.path.exists(fileCheck2): # "fileCheck2 is a file after renaming
print 'File "%s" exists already' % FILE
pass
else:
try:
f.cwd(DIRN + folder)
start = time.clock()
f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
end = time.clock()
arcpy.Rename_management(os.path.join(workspace, FILE), os.path.join(workspace, name))
except ftplib.error_perm:
print 'ERROR: cannot read file "%s"' % FILE
os.unlink(FILE)
. 아니면 단순히 os.unlink(FILE)
행을 삭제하면됩니다. 이 같은 오류를 처리하는 가장 좋은 방법은 무엇입니까?