Issue 6768: asyncore file_wrapper leaking file descriptors? (original) (raw)
Issue6768
Created on 2009-08-23 21:02 by keysers, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg91892 - (view) | Author: Daniel Keysers (keysers) | Date: 2009-08-23 21:02 |
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! | ||
msg104044 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * ![]() |
Date: 2010-04-23 20:21 |
I'm not sure how to reproduce this issue but I doubt calling close() from __del__ would solve the problem, neither would be a good idea as close() might end up being called more than once, which is not desirable. Try to paste the code you're using: the problem might be that your application is not calling close() for some reason. | ||
msg115696 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * ![]() |
Date: 2010-09-06 10:59 |
Closing out because no response has been provided by the OP. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:52 | admin | set | github: 51017 |
2010-09-06 10:59:00 | giampaolo.rodola | set | status: open -> closedresolution: wont fixmessages: + |
2010-09-04 23:21:52 | pitrou | set | assignee: giampaolo.rodolastage: needs patchversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6 |
2010-04-23 20:21:56 | giampaolo.rodola | set | messages: + |
2010-03-14 22:27:53 | giampaolo.rodola | set | nosy: + giampaolo.rodola |
2009-08-23 21:02:30 | keysers | create |