开发者

Checking when shutil.copyfile is done

开发者 https://www.devze.com 2023-01-04 22:41 出处:网络
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 shu

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 开发者_StackOverflow社区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?

0

精彩评论

暂无评论...
验证码 换一张
取 消