Obviously please close the file, ideally using something like the with-statement or at least finally. But for perhaps the convenience of scripters, and the sorrow of everyone else ;), Jython will close the file upon clean termination of the JVM via registering a closer of such files with Runtime#addShutdownHook<http://download.oracle.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)>
This is currently part of the most important outstanding bug<http://bugs.jython.org/issue1327>in Jython 2.5.2, and something that has to be resolved for 2.5.2 beta 2, because of how it interacts with classloaders and prevents their class GC upon reload (thus potentially exhausting permgen). On Fri, Aug 20, 2010 at 8:06 AM, Armin Rigo <[email protected]> wrote: > Hi Donny, > > On Fri, Aug 20, 2010 at 06:23:26AM -0400, Donny Viszneki wrote: > > Armin: Sakesun used "del f" and it appears you did not. In Python > > IIRC, an explicit call to del should kick off the finalizer to flush > > and close the file! > > No, you are wrong. Try for example: > > >>> f = open('xxx') > >>> g = f > >>> del f > > After this, 'g' still refers to the file, and it is still open. > > If you want the file to be flushed and closed, then call 'f.close()' :-) > > > A bientot, > > Armin. > _______________________________________________ > [email protected] > http://codespeak.net/mailman/listinfo/pypy-dev >
_______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
