nice-bill commited on
Commit
8b67b0f
·
verified ·
1 Parent(s): 1d98dac

deploy from github

Browse files
Files changed (1) hide show
  1. core/simulation.py +13 -10
core/simulation.py CHANGED
@@ -88,16 +88,19 @@ class Simulation:
88
  print(f"Boredom Penalty: Agents lose tokens after 2+ consecutive do_nothing actions")
89
  print()
90
 
91
- # Register graceful shutdown handler
92
- import signal
93
- def shutdown_handler(signum, frame):
94
- print(f"\n[SHUTDOWN] Received signal, saving progress...")
95
- _save_progress(self)
96
- print(f"[SHUTDOWN] Run marked as incomplete")
97
- raise SystemExit(0)
98
-
99
- signal.signal(signal.SIGTERM, shutdown_handler)
100
- signal.signal(signal.SIGINT, shutdown_handler)
 
 
 
101
 
102
  def _save_progress(sim):
103
  """Save current progress as incomplete run."""
 
88
  print(f"Boredom Penalty: Agents lose tokens after 2+ consecutive do_nothing actions")
89
  print()
90
 
91
+ # Register graceful shutdown handler (may not work in all environments)
92
+ try:
93
+ import signal
94
+ def shutdown_handler(signum, frame):
95
+ print(f"\n[SHUTDOWN] Received signal, saving progress...")
96
+ _save_progress(self)
97
+ print(f"[SHUTDOWN] Run marked as incomplete")
98
+ raise SystemExit(0)
99
+
100
+ signal.signal(signal.SIGTERM, shutdown_handler)
101
+ signal.signal(signal.SIGINT, shutdown_handler)
102
+ except (ValueError, AttributeError) as e:
103
+ print(f"[WARN] Signal handlers not available: {e}")
104
 
105
  def _save_progress(sim):
106
  """Save current progress as incomplete run."""