This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author keysers
Recipients keysers
Date 2009-08-23.21:02:29
SpamBayes Score 3.1270606e-08
Marked as misclassified No
Message-id <1251061355.88.0.439878311774.issue6768@psf.upfronthosting.co.za>
In-reply-to
Content
I'm not very experienced in Python, but while tracking down an issue 
with a "too many open files" error I think I found a missing resource 
release in asyncore's file_wrapper. Since Rev. 64062 added the os.dup() 
in __init__ this class reads as follows:

if os.name == 'posix':
    import fcntl

    class file_wrapper:
        # Here we override just enough to make a file
        # look like a socket for the purposes of asyncore.
        # The passed fd is automatically os.dup()'d

        def __init__(self, fd):
            self.fd = os.dup(fd)

        def recv(self, *args):
            return os.read(self.fd, *args)

        def send(self, *args):
            return os.write(self.fd, *args)

        read = recv
        write = send

        def close(self):
            os.close(self.fd)

        def fileno(self):
            return self.fd


I think that a "def __del__(self): self.close()" or a variant thereof 
would solve the problem I was seeing since it would release the file 
descriptor acquired in __init__ by os.dup(). But since I don't know why 
the os.dup() was added in the first place I'm not sure if there aren't 
any arguments against this release. Any comment appreciated!
History
Date User Action Args
2009-08-23 21:02:35keyserssetrecipients: + keysers
2009-08-23 21:02:35keyserssetmessageid: <1251061355.88.0.439878311774.issue6768@psf.upfronthosting.co.za>
2009-08-23 21:02:30keyserslinkissue6768 messages
2009-08-23 21:02:29keyserscreate