studio: catch KeyboardInterrupt in samples and format imports.
* Adds exception handler block to simulator samples to allow clean Ctrl+C exits. * Formats import statements inside code generator validator. PiperOrigin-RevId: 950821976 Change-Id: I283533d87619d5d9b54d9bec970cdefe538fd752
This commit is contained in:
committed by
Copybara-Service
parent
a62bf19e64
commit
8196ca17f8
@@ -184,9 +184,13 @@ def main(argv: list[str]) -> None:
|
|||||||
handle.send_to_viewer(messages.ModelEvent(model=model))
|
handle.send_to_viewer(messages.ModelEvent(model=model))
|
||||||
|
|
||||||
step_control = sim.StepControl()
|
step_control = sim.StepControl()
|
||||||
while handle.is_running():
|
try:
|
||||||
step_control.advance(model, data)
|
while handle.is_running():
|
||||||
model, data, step_control = handle.sync(model, data, step_control)
|
step_control.advance(model, data)
|
||||||
|
model, data, step_control = handle.sync(model, data, step_control)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
# Ctrl+C is the documented way to quit; exit cleanly, no traceback.
|
||||||
|
print('\nShutting down.', flush=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -237,9 +237,13 @@ def main(argv: list[str]) -> None:
|
|||||||
handle.send_to_viewer(messages.ModelEvent(model=model))
|
handle.send_to_viewer(messages.ModelEvent(model=model))
|
||||||
|
|
||||||
step_control = sim.StepControl()
|
step_control = sim.StepControl()
|
||||||
while handle.is_running():
|
try:
|
||||||
step_control.advance(model, data)
|
while handle.is_running():
|
||||||
model, data, step_control = handle.sync(model, data, step_control)
|
step_control.advance(model, data)
|
||||||
|
model, data, step_control = handle.sync(model, data, step_control)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
# Ctrl+C is the documented way to quit; exit cleanly, no traceback.
|
||||||
|
print('\nShutting down.', flush=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -61,9 +61,13 @@ def main(argv: list[str]) -> None:
|
|||||||
|
|
||||||
# Run the simulation.
|
# Run the simulation.
|
||||||
step_control = sim.StepControl()
|
step_control = sim.StepControl()
|
||||||
while handle.is_running():
|
try:
|
||||||
step_control.advance(model, data)
|
while handle.is_running():
|
||||||
model, data, step_control = handle.sync(model, data, step_control)
|
step_control.advance(model, data)
|
||||||
|
model, data, step_control = handle.sync(model, data, step_control)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
# Ctrl+C is the documented way to quit; exit cleanly, no traceback.
|
||||||
|
print('\nShutting down.', flush=True)
|
||||||
|
|
||||||
|
|
||||||
_app.run(main)
|
_app.run(main)
|
||||||
|
|||||||
Reference in New Issue
Block a user