summaryrefslogtreecommitdiff
path: root/zuul/cmd/__init__.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-06-04 02:48:28 +0000
committerGerrit Code Review <review@openstack.org>2014-06-04 02:48:28 +0000
commit9601f6463c2bc2cdbc97bbbd5632455e6c1dc5bf (patch)
treeda50db8f6757cce82b45e632676a8c6d927ec491 /zuul/cmd/__init__.py
parent53abc931d98dad7fbdc51d0cfa62d8b38ac316df (diff)
parentff4eeecc6a7ecf7bda28da8c3d7f5ec3ebefe111 (diff)
downloadzuul-9601f6463c2bc2cdbc97bbbd5632455e6c1dc5bf.tar.gz
Merge "Add toggleable yappi profiling to zuul"
Diffstat (limited to 'zuul/cmd/__init__.py')
-rw-r--r--zuul/cmd/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/zuul/cmd/__init__.py b/zuul/cmd/__init__.py
index 676f9b383..8ac3368a7 100644
--- a/zuul/cmd/__init__.py
+++ b/zuul/cmd/__init__.py
@@ -15,6 +15,8 @@
# under the License.
import ConfigParser
+import cStringIO
+import extras
import logging
import logging.config
import os
@@ -22,6 +24,8 @@ import signal
import sys
import traceback
+yappi = extras.try_import('yappi')
+
# No zuul imports here because they pull in paramiko which must not be
# imported until after the daemonization.
# https://github.com/paramiko/paramiko/issues/59
@@ -36,6 +40,17 @@ def stack_dump_handler(signum, frame):
log_str += "".join(traceback.format_stack(stack_frame))
log = logging.getLogger("zuul.stack_dump")
log.debug(log_str)
+ if yappi:
+ if not yappi.is_running():
+ yappi.start()
+ else:
+ yappi.stop()
+ yappi_out = cStringIO.StringIO()
+ yappi.get_func_stats().print_all(out=yappi_out)
+ yappi.get_thread_stats().print_all(out=yappi_out)
+ log.debug(yappi_out.getvalue())
+ yappi_out.close()
+ yappi.clear_stats()
signal.signal(signal.SIGUSR2, stack_dump_handler)