检查 Shutil.copyfile 何时完成

发布于 2024-09-07 15:46:33 字数 235 浏览 0 评论 0原文

我有这样的代码:

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

这是问题,在 #do future actions 我使用复制的文件,因此我需要确保 shutil.copyfile 函数完成它们的工作任务。我怎样才能确定这一点?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

饮湿 2024-09-14 15:46:33

Shutil 函数应仅在操作完成后返回。如果操作系统级别没有发生任何有趣的事情,那么这种方式应该是安全的。

如果您知道文件的大小,您可以检查这是否正确。

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.

生生漫 2024-09-14 15:46:33

copyfile 是一个阻塞函数。当您进行#do future actions时,它应该始终已完成。您是否遇到了不存在的问题?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文