@Matthew, I haven't created this ticket yet. "not all files are properly closed" was aimed at bugs.python.org I used the following monkeypatching code to debug the issue, but it doesn't cover all the cases a file descriptor can be opened.
import __builtin__ import inspect openfiles = set() oldfile = __builtin__.file class newfile(oldfile): def __init__(self, *args): self.x = args[0] print "### OPENING %s ###" % str(self.x) oldfile.__init__(self, *args) openfiles.add(self)
def close(self): print "### CLOSING %s ###" % str(self.x) oldfile.close(self) openfiles.remove(self) oldopen = __builtin__.open def newopen(*args): return newfile(*args) __builtin__.file = newfile __builtin__.open = newopen
def printOpenFiles(): print "### %d OPEN FILES: [%s]" % (len(openfiles), ", ".join(f.x for f in openfiles))
@Matthew, I haven't created this ticket yet. "not all files are properly closed" was aimed at bugs.python.org I used the following monkeypatching code to debug the issue, but it doesn't cover all the cases a file descriptor can be opened.
import __builtin__
oldfile. __init_ _(self, *args)
openfiles. add(self)
import inspect
openfiles = set()
oldfile = __builtin__.file
class newfile(oldfile):
def __init__(self, *args):
self.x = args[0]
print "### OPENING %s ###" % str(self.x)
def close(self):
oldfile. close(self)
openfiles. remove( self)
print "### CLOSING %s ###" % str(self.x)
oldopen = __builtin__.open
def newopen(*args):
return newfile(*args)
__builtin__.file = newfile
__builtin__.open = newopen
def printOpenFiles():
print "### %d OPEN FILES: [%s]" % (len(openfiles), ", ".join(f.x for f in openfiles))