if --profile is enabled, dump results every ten minutes, as well as at shutdown

This commit is contained in:
Noah Levitt 2017-12-21 11:13:37 -08:00
parent af6e5ea112
commit 399853dea0
2 changed files with 8 additions and 1 deletions

View File

@ -52,7 +52,7 @@ except:
setuptools.setup(
name='warcprox',
version='2.3.1b4.dev127',
version='2.3.1b4.dev128',
description='WARC writing MITM HTTP/S proxy',
url='https://github.com/internetarchive/warcprox',
author='Noah Levitt',

View File

@ -227,6 +227,7 @@ class WarcproxController(object):
self.start()
last_mem_dbg = datetime.datetime.utcfromtimestamp(0)
last_profile_dump = datetime.datetime.utcnow()
try:
utc = datetime.timezone.utc
@ -253,6 +254,12 @@ class WarcproxController(object):
# self.debug_mem()
# last_mem_dbg = datetime.datetime.utcnow()
if (self.options.profile and
(datetime.datetime.utcnow() - last_profile_dump
).total_seconds() > 60*10):
self._dump_profiling()
last_profile_dump = datetime.datetime.utcnow()
time.sleep(0.5)
if self.options.profile: