473,809 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fcntl O_NDELAY constant not found in python 2.3 on linux

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@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@linux01 python]$ python ./testfcntl.py

/usr/local/lib/python2.3/FCNTL.py:7:
DeprecationWarn ing: the FCNTL module is deprecated;
please use fcntl
DeprecationWarn ing)
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/

Jul 18 '05 #1
0 1558

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3835
by: Pierre Rouleau | last post by:
Hi all! I am using Python 2.3.1 on Win32 (NT, 2000). Whenever a file imports the standard tempfile module, Python 2.3.1 issues the following warning: C:\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is Deprecated; please use fcntl DeprecationWarning).
11
2626
by: Chris Green | last post by:
Hey folks, Is there anyway for a signal handler in python to get the information from a 3 argument signal handler rather than just the signal number and stack frame? I've got an application where I have to check for F_SETLEASE on a file in python on Linux 2.4. What this does is tells the kernel to notify the current process with SIGIO that a particular file descriptor is being modified by another process.
3
2279
by: Rob McCrea | last post by:
Hi all, On windows98SE, running Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32, the built-in help() function gives me a deprecation warning when used on my docstrings. just help() start the interactive help without error. Heres some minimalistic code to demonstrate this warning: """start testhelp.py"""
4
18346
by: Omid Fatemi | last post by:
I followed discussion in the group about this problem: ImportError: No module named fcntl I found out there are two modules: FCNTL fcntl the first one is obsolete and shouldn't be used. But the second one is usable.
0
1454
by: wicur | last post by:
this statement was OK in old version of perl: (my $constname = $AUTOLOAD) =~ s/.*:://; in v5.8.1 built for i386-linux-thread-multi returned Fcntl::AUTOLOAD(/usr/lib/perl5/5.8.1/i386-linux-thread-multi/Fcntl.pm:224): 224: die "&Fcntl::constant not defined" if $constname eq 'constant'; any suggestions are more then welcome
3
6604
by: thakadu | last post by:
The following code works as expected when run in the main body of a python script (ver 2.3.5) on OpenBSD v3.8. but when it is in the body of a function definition it does not work. It does not raise any errors but it simply does not block as expected. I have repeated this in both a cgi envirnoment and a non-cgi environment. I also have repeated it under OpenBSD 3.6 Python Version 2.3.4. To test this you need to run the code from two shells...
5
12318
by: marcello | last post by:
Hello I need to do this: 1 opening a file for writing/appending 2 to lock the file as for writing (i mean: the program that lock can keep writing, all others programs can't ) 3 wtite and close/unlock Even better would be changing the order of steps 1 and 2 (that is,first locking than writing, but it seems to me that in order to block i need the id of the file...)
9
5433
by: mhearne808[insert-at-sign-here]gmail[insert-dot-he | last post by:
I'm having a number of problems with the fcntl module. First off, my system info: Mac OS X Darwin igskcicglthearn.cr.usgs.gov 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386 Python 2.5.1 (built from source) OK, the weirdness:
2
3652
by: xucs007 | last post by:
I ran following 2 programs (lock1, lock2) at almost same time, to write either "123456", or "222" to file "aaa" at the same time. But I often just got "222456" in "aaa" . Is this a bug of python fcntl module ? See 2 programs I ran: #!/usr/bin/env python import fcntl, time
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.