New submission from Daniel Keysers <dkeys...@gmail.com>: 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! ---------- components: Library (Lib) messages: 91892 nosy: keysers severity: normal status: open title: asyncore file_wrapper leaking file descriptors? type: resource usage versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6768> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com