linux - Python - 找不到 fcntl.FNDELAY

标签 linux python-2.7

我想使用我在 15 年以上的 Python 书中找到的以下代码(由于向后移植问题,我们目前使用 Python 2.7,但下一个主要项目将转为 Python 3)。

import os, popen2, fcntl, select

def makeNonBlocking(fd):
    fl = fcntl.fcntl(fd, fcntl.F_GETFL)
    try:
        fcntl.fcntl(fd, fcntl.F_SETFL, fl | fcntl.O_NDELAY)
    except AttributeError:
        fcntl.fcntl(fd, fcntl.F_SETFL, fl | fcntl.FNDELAY)

问题是它找不到属性“fcntl.FNDELAY”。谷歌搜索一个多小时没有让我进一步。用 NULL 语句替换代码确认它正在查找 fcntl.O_NDELAY

操作系统是Linux Mint 17.3

最佳答案

快速谷歌搜索表明您可能正在寻找 os.O_NDELAY这在某些时候也被称为 os.FNDELAY

关于linux - Python - 找不到 fcntl.FNDELAY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47531788/

相关文章:

python - Flask + apache 发出请求或数据库时出现内部服务器错误

python - 无法为 Python 2.7 构建 OpenCV3.1

linux - 通过 FIFO 重定向标准输入

c++ - 在 Qt 中启动一个分离进程并处理端口

Linux 狂欢 : Move multiple different files into same directory

linux - 针对存储在数据库中的脚本执行 python

python - 如何在 Python 中将文件内容打印到控制台

linux - 无法安装快照

C-Linux-如何将C参数值发送给awk脚本?

python - 如何在python中使用子类的方法调用第二个父类的方法?