fcntl O_NDELAY constant not found in python 2.3 on linux

Ryan Grow ryangrow at yahoo.com
Fri Jan 23 20:05:41 CET 2004


I'm trying to use fcntl to set an existing file
descriptor to be nonblocking. This contrived example
exhibits the behavior of python that is preventing me
from doing this:

import os, fcntl, FCNTL

file = open("/tmp/testfd.txt", 'w')
fd = file.fileno()
fl = fcntl.fcntl(fd, FCNTL.F_GETFL)
fcntl.fcntl(fd, FCNTL.F_SETFL, fl | FCNTL.O_NDELAY)
print "Made it!"

When I run this in the following environment, it works

Linux Kernel 2.4.7-10
python 2.1.1

[rgrow at linux01 python]$ /usr/bin/python2.1
Made it!

However, when I run this with either python 2.3.2 or
2.3.3, I get the following output:

[rgrow at linux01 python]$ python ./testfcntl.py

DeprecationWarning: the FCNTL module is deprecated;
please use fcntl
Traceback (most recent call last):
  File "./testfcntl.py", line 6, in ?
    fcntl.fcntl(fd, FCNTL.F_SETFL, fl |
AttributeError: 'module' object has no attribute

What is the correct way that I should be making this
kind of a call in 2.3 to both avoid the deprecation
warning as well as the attribute error?



Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

More information about the Python-list mailing list