我们知道Python是否开放模式' x'实际上是一个原子“如果不存在的话”在窗户下?
根据 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论