gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 02:22:12 26 4
gpt4 key购买 nike

如下所示,我在 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 linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.O_EXLOCK
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'O_EXLOCK'
>>> os.O_DSYNC
4096
>>>

最佳答案

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相反。

关于python - os.O_EXLOCK(独占锁)在 Linux 上的 Python 中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12083536/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com