details: http://www.bx.psu.edu/hg/galaxy/rev/eef0fd813076 changeset: 1564:eef0fd813076 user: Nate Coraor <nate@bx.psu.edu> date: Mon Oct 20 15:09:47 2008 -0400 description: Add a Heapy-based memdump module. Send the Galaxy process SIGUSR1 and output of a few (hopefully) useful views of the heap is written to memdump.log. 4 file(s) affected in this change: lib/galaxy/app.py lib/galaxy/config.py lib/galaxy/tools/parameters/basic.py lib/galaxy/util/memdump.py diffs (84 lines): diff -r 98867708d5ae -r eef0fd813076 lib/galaxy/app.py --- a/lib/galaxy/app.py Mon Oct 20 14:16:38 2008 -0400 +++ b/lib/galaxy/app.py Mon Oct 20 15:09:47 2008 -0400 @@ -41,6 +41,11 @@ if heartbeat.Heartbeat: self.heartbeat = heartbeat.Heartbeat() self.heartbeat.start() + # Enable the memdump signal catcher if configured and available + if self.config.use_memdump: + from galaxy.util import memdump + if memdump.Memdump: + self.memdump = memdump.Memdump() def shutdown( self ): self.job_stop_queue.shutdown() self.job_queue.shutdown() diff -r 98867708d5ae -r eef0fd813076 lib/galaxy/config.py --- a/lib/galaxy/config.py Mon Oct 20 14:16:38 2008 -0400 +++ b/lib/galaxy/config.py Mon Oct 20 15:09:47 2008 -0400 @@ -56,6 +56,7 @@ self.pbs_dataset_path = kwargs.get('pbs_dataset_path', "" ) self.pbs_stage_path = kwargs.get('pbs_stage_path', "" ) self.use_heartbeat = string_as_bool( kwargs.get( 'use_heartbeat', "False" ) ) + self.use_memdump = kwargs.get( 'use_memdump', False ) self.ucsc_display_sites = kwargs.get( 'ucsc_display_sites', "main,test,archaea" ).lower().split(",") self.gbrowse_display_sites = kwargs.get( 'gbrowse_display_sites', "wormbase,flybase,elegans" ).lower().split(",") self.brand = kwargs.get( 'brand', None ) diff -r 98867708d5ae -r eef0fd813076 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py Mon Oct 20 14:16:38 2008 -0400 +++ b/lib/galaxy/tools/parameters/basic.py Mon Oct 20 15:09:47 2008 -0400 @@ -29,6 +29,7 @@ self.type = param.get("type") self.label = util.xml_text(param, "label") self.help = util.xml_text(param, "help") + self.unsanitize = param.get( "unsanitize", None ) self.html = "no html set" self.repeat = param.get("repeat", None) self.condition = param.get( "condition", None ) diff -r 98867708d5ae -r eef0fd813076 lib/galaxy/util/memdump.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/galaxy/util/memdump.py Mon Oct 20 15:09:47 2008 -0400 @@ -0,0 +1,43 @@ + +# Attempt to load guppy module, and only define Memdump class +# if available + +try: + + import pkg_resources + pkg_resources.require( "guppy" ) + +except: + + import sys + print >> sys.stderr, "No guppy module, Memdump not available" + Memdump = None + +else: + + import os, sys, signal, time, guppy + + class Memdump( object ): + def __init__( self, signum=signal.SIGUSR1, fname="memdump.log" ): + self.fname = fname + signal.signal( signum, self.dump ) + self.heapy = guppy.hpy() + def dump( self, signum, stack ): + file = open( self.fname, "a" ) + print >> file, "Memdump for pid %d at %s" % ( os.getpid(), time.asctime() ) + print >> file + try: + h = self.heapy.heap() + print >> file, "heap():" + print >> file, h + print >> file, "\nbyrcs:" + print >> file, h.byrcs + print >> file, "\nbyrcs[0].byid:" + print >> file, h.byrcs[0].byid + print >> file, "\nget_rp():" + print >> file, h.get_rp() + self.heapy.setref() + except AssertionError: + pass + print >> file, "\nEnd dump\n" + file.close()