Message91892
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! |
|
Date |
User |
Action |
Args |
2009-08-23 21:02:35 | keysers | set | recipients:
+ keysers |
2009-08-23 21:02:35 | keysers | set | messageid: <1251061355.88.0.439878311774.issue6768@psf.upfronthosting.co.za> |
2009-08-23 21:02:30 | keysers | link | issue6768 messages |
2009-08-23 21:02:29 | keysers | create | |
|