fcntl O_NDELAY constant not found in python 2.3 on linux

Ryan Grow ryangrow at yahoo.com
Fri Jan 23 14:05:41 EST 2004


Hi,

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
fine:

Linux Kernel 2.4.7-10
python 2.1.1


[rgrow at linux01 python]$ /usr/bin/python2.1
./testfcntl.py
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

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


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?

Thanks,

Ryan




__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/




More information about the Python-list mailing list