Run infinite loop with bot's command.
(bot_command, heartbeat_command)
| 188 | |
| 189 | |
| 190 | def run_loop(bot_command, heartbeat_command): |
| 191 | """Run infinite loop with bot's command.""" |
| 192 | atexit.register(stop_heartbeat) |
| 193 | if environment.is_android(): |
| 194 | atexit.register(stop_android_heartbeat) |
| 195 | |
| 196 | while True: |
| 197 | update_source_code_if_needed() |
| 198 | if not environment.is_uworker(): |
| 199 | if environment.is_android(): |
| 200 | start_android_heartbeat() |
| 201 | start_heartbeat(heartbeat_command) |
| 202 | exit_code = start_bot(bot_command) |
| 203 | if environment.is_uworker(): |
| 204 | logs.info(f'Job exited with code: {exit_code}. Exiting.') |
| 205 | sys.exit(exit_code) |
| 206 | |
| 207 | # See if our run timed out, if yes bail out. |
| 208 | try: |
| 209 | if data_handler.bot_run_timed_out(): |
| 210 | break |
| 211 | except Exception: |
| 212 | logs.error('Failed to check for bot run timeout.') |
| 213 | |
| 214 | sleep(LOOP_SLEEP_INTERVAL) |
| 215 | |
| 216 | |
| 217 | def set_start_time(): |
no test coverage detected