From 6476262f11a08164921a2d570b006a5229bc1943 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Wed, 28 Oct 2015 21:48:54 +0000 Subject: [PATCH] run warc writer thread with profiling enabled, dump results when shutting down --- warcprox/writerthread.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/warcprox/writerthread.py b/warcprox/writerthread.py index 76a6c2a..07441e7 100644 --- a/warcprox/writerthread.py +++ b/warcprox/writerthread.py @@ -16,6 +16,7 @@ from datetime import datetime import hanzo.httptools from hanzo import warctools import warcprox +import cProfile class WarcWriterThread(threading.Thread): logger = logging.getLogger("warcprox.warcproxwriter.WarcWriterThread") @@ -35,6 +36,9 @@ class WarcWriterThread(threading.Thread): self.idle = None def run(self): + cProfile.runctx('self._run()', globals(), locals(), sort='cumulative') + + def _run(self): try: self.setName('WarcWriterThread(tid={})'.format(warcprox.gettid())) while True: