diff --git a/buildscripts/setup_multiversion_mongodb.py b/buildscripts/setup_multiversion_mongodb.py index dcf65f77a76..9ba9fbf4983 100644 --- a/buildscripts/setup_multiversion_mongodb.py +++ b/buildscripts/setup_multiversion_mongodb.py @@ -7,6 +7,9 @@ import tempfile import urllib2 import subprocess import tarfile +import signal +import threading +import traceback import shutil import errno # To ensure it exists on the system @@ -17,6 +20,20 @@ import gzip # Only really tested/works on Linux. # +def dump_stacks(signal, frame): + print "======================================" + print "DUMPING STACKS due to SIGUSR1 signal" + print "======================================" + threads = threading.enumerate(); + + print "Total Threads: " + str(len(threads)) + + for id, stack in sys._current_frames().items(): + print "Thread %d" % (id) + print "".join(traceback.format_stack(stack)) + print "======================================" + + def version_tuple(version): """Returns a version tuple that can be used for numeric sorting of version strings such as '2.6.0-rc1' and '2.4.0'""" @@ -215,6 +232,12 @@ def parse_cl_args(args): def main(): + # Listen for SIGUSR1 and dump stack if received. + try: + signal.signal(signal.SIGUSR1, dump_stacks) + except AttributeError: + print "Cannot catch signals on Windows" + downloader, versions = parse_cl_args(sys.argv[1:]) for version in versions: