Linux上的Python中不存在os.O_EXLOCK(独占锁)

Linux上的Python中不存在os.O_EXLOCK(独占锁),第1张

概述正如您在下面看到的,我在 Linux(RHEL)上运行 Python 2.6,但由于某种原因它没有os.O_EXLOCK.有什么理由吗?有没有办法解决这个问题? Python 2.6.5 (r265:79063, Apr 9 2010, 11:16:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2Type "help", "copyr 正如您在下面看到的,我在 Linux(RHEL)上运行 Python 2.6,但由于某种原因它没有os.O_EXLOCK.有什么理由吗?有没有办法解决这个问题?

Python 2.6.5 (r265:79063,Apr  9 2010,11:16:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2Type "help","copyright","credits" or "license" for more information.>>> import os>>> os.O_EXLOCKTraceback (most recent call last):  file "<stdin>",line 1,in <module>AttributeError: 'module' object has no attribute 'O_EXLOCK'>>> os.O_DSYNC4096>>>
解决方法 如 the Python Standard Library documentation所述,

The following constants are options for the flags parameter to the
open() function. They can be combined using the bitwise OR operator |.
Some of them are not available on all platforms. For descriptions of
their availability and use,consult the open(2) manual page on Unix or
the MSDN on windows.

O_EXLOCK originated in the BSD world;它通常不适用于linux.您也许可以使用Python fcntl module.

总结

以上是内存溢出为你收集整理的Linux上的Python中不存在os.O_EXLOCK(独占锁)全部内容,希望文章能够帮你解决Linux上的Python中不存在os.O_EXLOCK(独占锁)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/1023467.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存