Skip to content

Commit 28dc49d

Browse files
committed
Run image checks in parallel
1 parent c70e916 commit 28dc49d

File tree

3 files changed

+201
-166
lines changed

3 files changed

+201
-166
lines changed

internal/devtools.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1486,10 +1486,10 @@ def process_message(self, msg, target_id=None):
14861486
if len(parts) >= 2:
14871487
category = parts[0]
14881488
event = parts[1]
1489-
log_event = bool(self.recording)
1489+
log_event = bool(self.capturing)
14901490
if category == 'Page' and self.recording:
14911491
self.process_page_event(event, msg)
1492-
elif category == 'Network' and self.recording:
1492+
elif category == 'Network':
14931493
self.process_network_event(event, msg, target_id)
14941494
elif category == 'Console' and self.recording:
14951495
self.process_console_event(event, msg)
@@ -1681,7 +1681,7 @@ def process_network_event(self, event, msg, target_id=None):
16811681
except Exception:
16821682
logging.exception('Error processing host override')
16831683
self.send_command('Network.continueInterceptedRequest', params, target_id=target_id)
1684-
elif 'requestId' in msg['params']:
1684+
elif 'requestId' in msg['params'] and self.capturing:
16851685
timestamp = None
16861686
if 'params' in msg and 'timestamp' in msg['params']:
16871687
timestamp = msg['params']['timestamp']

internal/devtools_browser.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -574,17 +574,6 @@ def collect_browser_metrics(self, task):
574574
"""Collect all of the in-page browser metrics that we need"""
575575
if self.must_exit_now:
576576
return
577-
user_timing = self.run_js_file('user_timing.js')
578-
if user_timing is not None:
579-
path = os.path.join(task['dir'], task['prefix'] + '_timed_events.json.gz')
580-
with gzip.open(path, GZIP_TEXT, 7) as outfile:
581-
outfile.write(json.dumps(user_timing))
582-
page_data = self.run_js_file('page_data.js')
583-
self.document_domain = None
584-
if page_data is not None:
585-
if 'document_hostname' in page_data:
586-
self.document_domain = page_data['document_hostname']
587-
task['page_data'].update(page_data)
588577
if 'customMetrics' in self.job:
589578
requests = None
590579
dns_info = None
@@ -671,6 +660,8 @@ def collect_browser_metrics(self, task):
671660

672661
def finish_collect_browser_metrics(self, task):
673662
""" Collect the asyc custom metrics results"""
663+
if self.must_exit_now:
664+
return
674665
try:
675666
if self.custom_metrics_command_ids:
676667
custom_metrics = {}
@@ -694,6 +685,17 @@ def finish_collect_browser_metrics(self, task):
694685
with gzip.open(path, GZIP_TEXT, 7) as outfile:
695686
outfile.write(json.dumps(custom_metrics))
696687
self.custom_metrics_command_ids = None
688+
user_timing = self.run_js_file('user_timing.js')
689+
if user_timing is not None:
690+
path = os.path.join(task['dir'], task['prefix'] + '_timed_events.json.gz')
691+
with gzip.open(path, GZIP_TEXT, 7) as outfile:
692+
outfile.write(json.dumps(user_timing))
693+
page_data = self.run_js_file('page_data.js')
694+
self.document_domain = None
695+
if page_data is not None:
696+
if 'document_hostname' in page_data:
697+
self.document_domain = page_data['document_hostname']
698+
task['page_data'].update(page_data)
697699
except Exception:
698700
logging.exception('Error collecting async custom metrics results')
699701

0 commit comments

Comments
 (0)