문제

I have a such code:

for file in file_list:
    shutil.copyfile(file,newpath)
#do further actions

And here is the question, at #do further actions I use the copied f iles thus I need to make sure the shutil.copyfile functions finish their task. How can I make sure of this ?

도움이 되었습니까?

해결책

The shutil functions should return only after the operation is finished. If nothing funny is going on on the OS level it should be safe this way.

If you know the size of the file you could check if that is correct.

다른 팁

copyfile is a blocking function. By the time you get to #do further actions it should always be done. Are you having issues where it isn't?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top