diff options
Diffstat (limited to 'bin/handler.py')
-rw-r--r-- | bin/handler.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/handler.py b/bin/handler.py index 40fafea..3325391 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -20,12 +20,14 @@ console response. This ability gives an user a whole lot of power, and should be used with care. """ -import os import curses +import os +import time class Handler: KEY_ESCAPE = 27 + CYCLE_TIMEOUT = 0.1 def __init__(self, sim): """ Handler constructor. Simply link this class to the main simulation @@ -195,12 +197,18 @@ class Handler: raise RuntimeError(message) def __cycle_sim(self, factor): - """ Simply cycle Salis 'factor' number of times. + """ Simply cycle Salis 'factor' number of times. Do not cycle for more + than a given amount of time. """ + time_max = time.time() + self.CYCLE_TIMEOUT + for _ in range(factor): self.__sim.lib.sal_main_cycle() self.__sim.check_autosave() + if time.time() > time_max: + break + def __get_inst_dict(self): """ Transform the instruction list of the printer module into a dictionary that's more useful for genome compilation. Instruction |