@@ -818,10 +818,6 @@ def __init__(self, config: StatsConfig, parents: Sequence[Stats]):
818818 self ._last_update_time = 0
819819 self ._last_report_time = 0
820820 self ._summary_dispatcher = None
821- if self ._config .stats_out_queue :
822- self ._summary_dispatcher = self ._send_stats_to_main_process_loop
823- elif self ._config .log_summary :
824- self ._summary_dispatcher = self ._logging_execution_summary_loop
825821
826822 def __reduce__ (self ):
827823 return _ExecutionStats , (self ._config , self ._parents )
@@ -939,14 +935,18 @@ def record_self_time(self, num_elements: int = 1, offset_ns: int = 0):
939935 target = self ._reporting_loop , daemon = True
940936 )
941937 self ._reporting_thread .start ()
942- if (
943- self ._summary_dispatcher_thread is None
944- and self ._summary_dispatcher is not None
938+ if self ._summary_dispatcher_thread is None and (
939+ self ._config .stats_out_queue or self ._config .log_summary
945940 ):
946941 with self ._summary_dispatcher_thread_init_lock :
947942 # Check above together with update would not be atomic -- another
948943 # thread may have started the logging thread.
949944 if self ._summary_dispatcher_thread is None :
945+ self ._summary_dispatcher = (
946+ self ._send_stats_to_main_process_loop
947+ if self ._config .stats_out_queue
948+ else self ._logging_execution_summary_loop
949+ )
950950 self ._summary_dispatcher_thread = threading .Thread (
951951 target = self ._summary_dispatcher , daemon = True
952952 )
0 commit comments