@@ -506,43 +506,44 @@ def execute_command_sequence(
506506 success = False , visit_id = self .curr_visit_id
507507 )
508508 break
509+ with _tracer .start_as_current_span ("post_cs_chores" ):
510+ self .logger .info (
511+ "Finished working on CommandSequence with "
512+ "visit_id %d on browser with id %d" ,
513+ self .curr_visit_id ,
514+ self .browser_id ,
515+ )
516+ # Sleep after executing CommandSequence to provide extra time for
517+ # internal buffers to drain. Stopgap in support of #135
518+ time .sleep (2 )
509519
510- self .logger .info (
511- "Finished working on CommandSequence with "
512- "visit_id %d on browser with id %d" ,
513- self .curr_visit_id ,
514- self .browser_id ,
515- )
516- # Sleep after executing CommandSequence to provide extra time for
517- # internal buffers to drain. Stopgap in support of #135
518- time .sleep (2 )
519-
520- if task_manager .closing :
521- return
522-
523- # Allow StorageWatchdog to utilize built-in browser reset functionality
524- # which results in a graceful restart of the browser instance
525- if self .browser_params .maximum_profile_size :
526- assert self .current_profile_path is not None
520+ if task_manager .closing :
521+ return
527522
528- reset = profile_size_exceeds_max_size (
529- self . current_profile_path ,
530- self .browser_params .maximum_profile_size ,
531- )
523+ # Allow StorageWatchdog to utilize built-in browser reset functionality
524+ # which results in a graceful restart of the browser instance
525+ if self .browser_params .maximum_profile_size :
526+ assert self . current_profile_path is not None
532527
533- if self .restart_required or reset :
534- success = self .restart_browser_manager (clear_profile = reset )
535- if not success :
536- self .logger .critical (
537- "BROWSER %i: Exceeded the maximum allowable consecutive "
538- "browser launch failures. Setting failure_status." % self .browser_id
528+ reset = profile_size_exceeds_max_size (
529+ self .current_profile_path ,
530+ self .browser_params .maximum_profile_size ,
539531 )
540- task_manager .failure_status = {
541- "ErrorType" : "ExceedLaunchFailureLimit" ,
542- "CommandSequence" : command_sequence ,
543- }
544- return
545- self .restart_required = False
532+
533+ if self .restart_required or reset :
534+ success = self .restart_browser_manager (clear_profile = reset )
535+ if not success :
536+ self .logger .critical (
537+ "BROWSER %i: Exceeded the maximum allowable consecutive "
538+ "browser launch failures. Setting failure_status."
539+ % self .browser_id
540+ )
541+ task_manager .failure_status = {
542+ "ErrorType" : "ExceedLaunchFailureLimit" ,
543+ "CommandSequence" : command_sequence ,
544+ }
545+ return
546+ self .restart_required = False
546547
547548 def _unpack_pickled_error (self , pickled_error : bytes ) -> Tuple [str , str ]:
548549 """Unpacks `pickled_error` into an error `message` and `tb` string."""
@@ -677,6 +678,7 @@ def __init__(
677678 crash_recovery : bool ,
678679 ) -> None :
679680 super ().__init__ ()
681+ self .name = "BrowserManager"
680682 self .logger = logging .getLogger ("openwpm" )
681683 self .command_queue = command_queue
682684 self .status_queue = status_queue
0 commit comments