Add flag and setting for thread deadlock debug tool.

This commit is contained in:
Thomas Adamcik 2012-11-08 22:54:35 +01:00
parent b37e6a9ded
commit 81a3b41bc4
2 changed files with 18 additions and 4 deletions

View File

@ -40,14 +40,16 @@ logger = logging.getLogger('mopidy.main')
def main():
debug_thread = process.DebugThread()
debug_thread.start()
signal.signal(signal.SIGUSR1, debug_thread.handler)
signal.signal(signal.SIGTERM, process.exit_handler)
loop = gobject.MainLoop()
options = parse_options()
if options.debug_thread or settings.DEBUG_THREAD:
debug_thread = process.DebugThread()
debug_thread.start()
signal.signal(signal.SIGUSR1, debug_thread.handler)
try:
log.setup_logging(options.verbosity_level, options.save_debug_log)
check_old_folders()
@ -104,6 +106,10 @@ def parse_options():
'--list-deps',
action='callback', callback=deps.list_deps_optparse_callback,
help='list dependencies and their versions')
parser.add_option(
'--debug-thread',
action='store_true', dest='debug_thread',
help='run background thread that dumps tracebacks on SIGUSR1')
return parser.parse_args(args=mopidy_args)[0]

View File

@ -45,6 +45,14 @@ DEBUG_LOG_FORMAT = u'%(levelname)-8s %(asctime)s' + \
#: DEBUG_LOG_FILENAME = u'mopidy.log'
DEBUG_LOG_FILENAME = u'mopidy.log'
#: If we should start a background thread that dumps thread's traceback when we
#: get a SIGUSR1. Mainly a debug tool for figuring out deadlocks.
#:
#: Default::
#:
#: DEBUG_THREAD = False
DEBUG_THREAD = False
#: Location of the Mopidy .desktop file.
#:
#: Used by :mod:`mopidy.frontends.mpris`.