7979
8080HEARTBEAT_INTERVAL : int = 60
8181RESOURCES_METRIC_PREFIX : str = "resources"
82+ TOTAL_GRID_METRIC_SIZE : int = 1e6
8283MAXIMUM_GRID_METRIC_SIZE : int = 5 * 10 ** 4
8384
8485logger = logging .getLogger (__name__ )
@@ -547,7 +548,7 @@ def _start(self) -> bool:
547548 mode = self ._dispatch_mode ,
548549 termination_trigger = self ._shutdown_event ,
549550 object_types = ["events" , "metrics_regular" , "metrics_tensor" ],
550- thresholds = dict (object_size = MAXIMUM_GRID_METRIC_SIZE ),
551+ thresholds = dict (object_size = TOTAL_GRID_METRIC_SIZE ),
551552 callback = self ._create_dispatch_callback (),
552553 )
553554
@@ -584,12 +585,6 @@ def _error(self, message: str, join_threads: bool = True) -> None:
584585 RuntimeError
585586 exception throw
586587 """
587- # Stop heartbeat
588- if self ._heartbeat_termination_trigger and self ._heartbeat_thread :
589- self ._heartbeat_termination_trigger .set ()
590- if join_threads :
591- self ._heartbeat_thread .join ()
592-
593588 # Finish stopping all threads
594589 if self ._shutdown_event :
595590 self ._shutdown_event .set ()
@@ -600,6 +595,12 @@ def _error(self, message: str, join_threads: bool = True) -> None:
600595 if join_threads :
601596 self ._dispatcher .join ()
602597
598+ # Stop heartbeat
599+ if self ._heartbeat_termination_trigger and self ._heartbeat_thread :
600+ self ._heartbeat_termination_trigger .set ()
601+ if join_threads :
602+ self ._heartbeat_thread .join ()
603+
603604 if not self ._suppress_errors :
604605 raise SimvueRunError (message )
605606
@@ -1860,10 +1861,6 @@ def set_status(
18601861 def _tidy_run (self ) -> None :
18611862 self ._executor .wait_for_completion ()
18621863
1863- if self ._heartbeat_thread and self ._heartbeat_termination_trigger :
1864- self ._heartbeat_termination_trigger .set ()
1865- self ._heartbeat_thread .join ()
1866-
18671864 if self ._shutdown_event :
18681865 self ._shutdown_event .set ()
18691866
@@ -1876,6 +1873,10 @@ def _tidy_run(self) -> None:
18761873 self ._dispatcher .purge ()
18771874 self ._dispatcher .join ()
18781875
1876+ if self ._heartbeat_thread and self ._heartbeat_termination_trigger :
1877+ self ._heartbeat_termination_trigger .set ()
1878+ self ._heartbeat_thread .join ()
1879+
18791880 if (
18801881 self ._sv_obj
18811882 and self ._user_config .run .mode == "offline"
0 commit comments