File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -352,6 +352,7 @@ def __init__(
352
352
model = self .model ,
353
353
model_param_partition_specs = model_param_partition_specs ,
354
354
)
355
+ register_sigterm_handler ()
355
356
self ._maybe_record_event (measurement .Event .END_ACCELERATOR_INIT )
356
357
357
358
@property
@@ -1450,3 +1451,12 @@ def m_or_g(x, suffix=""):
1450
1451
logging .warning ("Attempt to parse cost_stats=%s but failed." , cost_stats )
1451
1452
1452
1453
return analysis_results
1454
+
1455
+ def register_sigterm_handler ():
1456
+ original_sigterm_handler = signal .getsignal (signal .SIGTERM )
1457
+ def sigterm_handler (signum , frame ):
1458
+ original_sigterm_handler (signum , frame )
1459
+
1460
+ # system is being shutdown
1461
+ if os .path .exists ("/var/run/nologin" ) or os .path .exists ("/run/nologin" ):
1462
+ raise SystemExit (f"Exiting without waiting checkpoint saving after system shutdown is detected." )
You can’t perform that action at this time.
0 commit comments