Skip to content

Commit 5c7da90

Browse files
committed
Better handling of Ctrl-c to exit.
PiperOrigin-RevId: 212704642
1 parent 12f6888 commit 5c7da90

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

pysc2/bin/play_vs_agent.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,17 @@ def human():
234234
fps=FLAGS.fps, render_feature_grid=False)
235235
renderer.run(run_configs.get(), controller, max_episodes=1)
236236
else: # Still step forward so the Mac/Windows renderer works.
237-
try:
238-
while True:
239-
frame_start_time = time.time()
240-
if not FLAGS.realtime:
241-
controller.step()
242-
obs = controller.observe()
243-
244-
if obs.player_result:
245-
break
246-
time.sleep(max(0, frame_start_time - time.time() + 1 / FLAGS.fps))
247-
except KeyboardInterrupt:
248-
pass
237+
while True:
238+
frame_start_time = time.time()
239+
if not FLAGS.realtime:
240+
controller.step()
241+
obs = controller.observe()
249242

243+
if obs.player_result:
244+
break
245+
time.sleep(max(0, frame_start_time - time.time() + 1 / FLAGS.fps))
246+
except KeyboardInterrupt:
247+
pass
250248
finally:
251249
if tcp_conn:
252250
tcp_conn.close()

0 commit comments

Comments
 (0)