run warc writer thread with profiling enabled, dump results when shutting down

This commit is contained in:
Noah Levitt 2015-10-28 21:48:54 +00:00
parent e0fe06c891
commit 6476262f11

View File

@ -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: