[hg] galaxy 1686: Since tempfiles seem to occasionally be left b...
details: http://www.bx.psu.edu/hg/galaxy/rev/696fc4c02a0c changeset: 1686:696fc4c02a0c user: Nate Coraor <nate@bx.psu.edu> date: Tue Dec 23 13:28:27 2008 -0500 description: Since tempfiles seem to occasionally be left behind, allow logging of open tempfiles, including a traceback (to determine callers) if LOG_TEMPFILES is set in the environment when Galaxy starts. This should be considered temporary and will be removed when it's determined where/how this happens. 2 file(s) affected in this change: lib/log_tempfile.py scripts/paster.py diffs (46 lines): diff -r 82886ba9323b -r 696fc4c02a0c lib/log_tempfile.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/log_tempfile.py Tue Dec 23 13:28:27 2008 -0500 @@ -0,0 +1,27 @@ +# override tempfile methods for debugging + +import tempfile, traceback + +import logging +log = logging.getLogger( __name__ ) + +class TempFile( object ): + def __init__( self ): + tempfile._NamedTemporaryFile = tempfile.NamedTemporaryFile + tempfile._mkstemp = tempfile.mkstemp + tempfile.NamedTemporaryFile = self.NamedTemporaryFile + tempfile.mkstemp = self.mkstemp + def NamedTemporaryFile( self, *args, **kwargs ): + f = tempfile._NamedTemporaryFile( *args, **kwargs ) + try: + log.debug( ( "Opened tempfile %s with NamedTemporaryFile:\n" % f.name ) + "".join( traceback.format_stack() ) ) + except AttributeError: + pass + return f + def mkstemp( self, *args, **kwargs ): + f = tempfile._mkstemp( *args, **kwargs ) + try: + log.debug( ( "Opened tempfile %s with mkstemp:\n" % f[1] ) + "".join( traceback.format_stack() ) ) + except TypeError: + pass + return f diff -r 82886ba9323b -r 696fc4c02a0c scripts/paster.py --- a/scripts/paster.py Mon Dec 22 13:35:01 2008 -0500 +++ b/scripts/paster.py Tue Dec 23 13:28:27 2008 -0500 @@ -16,6 +16,11 @@ from galaxy import eggs import pkg_resources +if 'LOG_TEMPFILES' in os.environ: + from log_tempfile import TempFile + _log_tempfile = TempFile() + import tempfile + pkg_resources.require( "PasteScript" ) from paste.script import command
participants (1)
-
Nate Coraor