You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes sense for SimulationSet runs. The events are already serialized, the missing bit is dumping the current FleetState/Vehicle states/stoplists/current time/request generator state to disk before exiting. This should probably handle both keyboard interrupts and signals.
Example for keyboard interrupts:
importtimetry:
whileTrue:
time.sleep(1)
print("doing something in a loop ...")
exceptKeyboardInterrupt:
print('Exiting gracefully.... byebye')
Examples for signals:
importsignalimporttimeclassGracefulKiller:
kill_now=Falsedef__init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
signal.signal(signal.SIGQUIT, self.exit_gracefully)
defexit_gracefully(self, signum, frame):
self.kill_now=Trueif__name__=='__main__':
killer=GracefulKiller()
whilenotkiller.kill_now:
time.sleep(1)
print("doing something in a loop ...")
print("End of the program. I was killed gracefully :)")
(IPython sends KeyboardInterrupt on hitting the stop button.)
Crucially, it's likely not sufficient to just write pickles to disk. The exact step at which the simulation was interrupted needs to be found, discarding the incomplete step and storing the last state before the interruption. Also, a line in a file might be written partially, stoplists may not have been updated, etc.
The text was updated successfully, but these errors were encountered:
This makes sense for SimulationSet runs. The events are already serialized, the missing bit is dumping the current FleetState/Vehicle states/stoplists/current time/request generator state to disk before exiting. This should probably handle both keyboard interrupts and signals.
Example for keyboard interrupts:
Examples for signals:
(IPython sends
KeyboardInterrupt
on hitting the stop button.)Crucially, it's likely not sufficient to just write pickles to disk. The exact step at which the simulation was interrupted needs to be found, discarding the incomplete step and storing the last state before the interruption. Also, a line in a file might be written partially, stoplists may not have been updated, etc.
The text was updated successfully, but these errors were encountered: