我们知道Python是否开放模式' x'实际上是一个原子“如果不存在的话”在窗户下?

发布于 2025-01-29 10:08:02 字数 830 浏览 3 评论 0原文

根据 OS中的功能,我假设它类似于高级Open在文件访问模式下,o_excl的行为标志取决于基础操作系统,并链接到Linux和Windows的文档。可以从 github repo python的C代码。

linux page 但是 Windows页面没有提及有关原子的任何内容。

任何人都可以提供证据表明“ X”模式确实是原子能的,因此在检查文件的存在和创建文件之间不可能发生种族条件吗?

According to the documentation of the open function in os, which I assume is analogous to the high level open function in terms of file access modes, the behaviour of the O_EXCL flag depends on the underlying operating system, and links to documentation for Linux and Windows. Evidence that 'x' mode is equivalent to O_EXCL|O_CREAT can be seen from the GitHub repo of Python's C code.

The Linux page says O_EXCL is atomic, but the Windows page doesn't mention anything about atomicity.

Can any one give evidence that the 'x' mode is indeed atomic under Windows such that there cannot be a race condition where something can happen between checking the file's existence and creating the file?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文