@@ -574,17 +574,6 @@ def collect_browser_metrics(self, task):
574
574
"""Collect all of the in-page browser metrics that we need"""
575
575
if self .must_exit_now :
576
576
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 )
588
577
if 'customMetrics' in self .job :
589
578
requests = None
590
579
dns_info = None
@@ -671,6 +660,8 @@ def collect_browser_metrics(self, task):
671
660
672
661
def finish_collect_browser_metrics (self , task ):
673
662
""" Collect the asyc custom metrics results"""
663
+ if self .must_exit_now :
664
+ return
674
665
try :
675
666
if self .custom_metrics_command_ids :
676
667
custom_metrics = {}
@@ -694,6 +685,17 @@ def finish_collect_browser_metrics(self, task):
694
685
with gzip .open (path , GZIP_TEXT , 7 ) as outfile :
695
686
outfile .write (json .dumps (custom_metrics ))
696
687
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 )
697
699
except Exception :
698
700
logging .exception ('Error collecting async custom metrics results' )
699
701
0 commit comments