[ python-Bugs-1025525 ] asyncore.file_dispatcher should not take fd as argument

SourceForge.net noreply at sourceforge.net
Fri Sep 10 04:14:51 CEST 2004


Bugs item #1025525, was opened at 2004-09-10 12:14
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1025525&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: david houlder (dhoulder)
Assigned to: Nobody/Anonymous (nobody)
Summary: asyncore.file_dispatcher should not take fd as argument

Initial Comment:
Only relevant to posix.
asyncore.file_dispatcher closes the file descriptor
behind the file object, and not the file object itself.
When another file gets opened, it gets the next
available fd, which on posix, is the one just released
by the close.

Tested on python 2.2.3 on RedHat Enterprise Linux 3 and
python 2.2.1 on HP Tru64 unix. See attached script for
details and a solution. 'case 1' should show the
problem regardless of the garbage collection strategy
in python. 'case 2' relies on the file object being
closed as soon as the last reference to it disappears,
which seems to be the (current?) behaviour.

[djh900 at dh djh900]$ python file_dispatcher_bug.py
case 1:
 (Read 'I am the first pipe\n' from pipe)
 (pipe closing. fd== 3 )
 (Read '' from pipe)
firstPipe.read() says 'I am the second pipe\n'
firstPipe.fileno()== 3
secondPipe.fileno()== 3

case 2:
 (Read 'I am the first pipe\n' from pipe)
 (pipe closing. fd== 3 )
 (Read '' from pipe)
secondPipe.fileno()== 3
dispatcher.secondPipe.read() says
Traceback (most recent call last):
  File "file_dispatcher_bug.py", line 77, in ?
    print "dispatcher.secondPipe.read() says",
repr(dispatcher.secondPipe.read())
IOError: [Errno 9] Bad file descriptor
[djh900 at dh djh900]$ 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1025525&group_id=5470


More information about the Python-bugs-list mailing list