Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions rlgym_ppo/learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ def _learn(self):
"""

# Class to watch for keyboard hits
kb = KBHit()
print("Press (p) to pause (c) to checkpoint, (q) to checkpoint and quit (after next iteration)\n")
try:
kb = KBHit()
print("Press (p) to pause (c) to checkpoint, (q) to checkpoint and quit (after next iteration)\n")
except:
# Disable if error initializing (job not running in a terminal probably)
kb = None

# While the number of timesteps we have collected so far is less than the
# amount we are allowed to collect.
Expand Down Expand Up @@ -270,7 +274,7 @@ def _learn(self):
# p: pause, any key to resume
# c: checkpoint
# q: checkpoint and quit
if kb.kbhit():
if kb is not None and kb.kbhit():
c = kb.getch()
if c == 'p': # pause
print("Paused, press any key to resume")
Expand Down