fix mistakes in warc write thread profile aggregation

This commit is contained in:
Noah Levitt 2017-11-14 17:14:21 -08:00
parent 5c2c21de07
commit fdfc84cea0
2 changed files with 3 additions and 6 deletions

View File

@ -283,12 +283,11 @@ class WarcproxController(object):
'aggregate performance profile of %s proxy threads:\n%s', 'aggregate performance profile of %s proxy threads:\n%s',
len(files), buf.getvalue()) len(files), buf.getvalue())
# warc writer threads # warc writer threads
files = [] files = []
for wwt in self.warc_writer_threads: for wwt in self.warc_writer_threads:
file = os.path.join(tmpdir, '%s.dat' % th_id) file = os.path.join(tmpdir, '%s.dat' % wwt.ident)
profiler.dump_stats(file) wwt.profiler.dump_stats(file)
files.append(file) files.append(file)
buf = io.StringIO() buf = io.StringIO()

View File

@ -56,12 +56,10 @@ class WarcWriterThread(threading.Thread):
self.idle = None self.idle = None
self.method_filter = set(method.upper() for method in self.options.method_filter or []) self.method_filter = set(method.upper() for method in self.options.method_filter or [])
def run(self):
if self.options.profile: if self.options.profile:
import cProfile import cProfile
self.profiler = cProfile.Profile() self.profiler = cProfile.Profile()
def run(self):
if self.options.profile:
self.profiler.enable() self.profiler.enable()
self._run() self._run()
self.profiler.disable() self.profiler.disable()