Spaces:
Sleeping
Sleeping
TheYoBots commited on
Commit ·
508b9db
1
Parent(s): 1dc506a
Revert "Put Active Correspondence Games into Queue on Startup"
Browse files- lishogi-bot.py +12 -21
lishogi-bot.py
CHANGED
|
@@ -113,7 +113,6 @@ def start(li, user_profile, engine_factory, config, logging_level, log_filename,
|
|
| 113 |
correspondence_pinger.start()
|
| 114 |
correspondence_queue = manager.Queue()
|
| 115 |
correspondence_queue.put("")
|
| 116 |
-
startup_correspondence_games = [game["gameId"] for game in li.get_ongoing_games() if game["perf"] == 'correspondence']
|
| 117 |
wait_for_correspondence_ping = False
|
| 118 |
|
| 119 |
busy_processes = 0
|
|
@@ -161,22 +160,17 @@ def start(li, user_profile, engine_factory, config, logging_level, log_filename,
|
|
| 161 |
except:
|
| 162 |
pass
|
| 163 |
elif event["type"] == "gameStart":
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
logger.info("--- Enqueue {}".format(config["url"] + game_id))
|
| 167 |
-
correspondence_queue.put(game_id)
|
| 168 |
-
startup_correspondence_games.remove(game_id)
|
| 169 |
else:
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
if (is_correspondence_ping or (is_local_game_done and not wait_for_correspondence_ping)) and not challenge_queue:
|
| 179 |
-
if is_correspondence_ping and wait_for_correspondence_ping:
|
| 180 |
correspondence_queue.put("")
|
| 181 |
|
| 182 |
wait_for_correspondence_ping = False
|
|
@@ -184,11 +178,8 @@ def start(li, user_profile, engine_factory, config, logging_level, log_filename,
|
|
| 184 |
game_id = correspondence_queue.get()
|
| 185 |
# stop checking in on games if we have checked in on all games since the last correspondence_ping
|
| 186 |
if not game_id:
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
else:
|
| 190 |
-
wait_for_correspondence_ping = True
|
| 191 |
-
break
|
| 192 |
else:
|
| 193 |
busy_processes += 1
|
| 194 |
logger.info("--- Process Used. Total Queued: {}. Total Used: {}".format(queued_processes, busy_processes))
|
|
|
|
| 113 |
correspondence_pinger.start()
|
| 114 |
correspondence_queue = manager.Queue()
|
| 115 |
correspondence_queue.put("")
|
|
|
|
| 116 |
wait_for_correspondence_ping = False
|
| 117 |
|
| 118 |
busy_processes = 0
|
|
|
|
| 160 |
except:
|
| 161 |
pass
|
| 162 |
elif event["type"] == "gameStart":
|
| 163 |
+
if queued_processes <= 0:
|
| 164 |
+
logger.debug("Something went wrong. Game is starting and we don't have a queued process")
|
|
|
|
|
|
|
|
|
|
| 165 |
else:
|
| 166 |
+
queued_processes -= 1
|
| 167 |
+
busy_processes += 1
|
| 168 |
+
logger.info("--- Process Used. Total Queued: {}. Total Used: {}".format(queued_processes, busy_processes))
|
| 169 |
+
game_id = event["game"]["id"]
|
| 170 |
+
pool.apply_async(play_game, [li, game_id, control_queue, engine_factory, user_profile, config, challenge_queue, correspondence_queue, logging_queue, game_logging_configurer, logging_level])
|
| 171 |
+
|
| 172 |
+
if (event["type"] == "correspondence_ping" or (event["type"] == "local_game_done" and not wait_for_correspondence_ping)) and not challenge_queue:
|
| 173 |
+
if event["type"] == "correspondence_ping" and wait_for_correspondence_ping:
|
|
|
|
|
|
|
| 174 |
correspondence_queue.put("")
|
| 175 |
|
| 176 |
wait_for_correspondence_ping = False
|
|
|
|
| 178 |
game_id = correspondence_queue.get()
|
| 179 |
# stop checking in on games if we have checked in on all games since the last correspondence_ping
|
| 180 |
if not game_id:
|
| 181 |
+
wait_for_correspondence_ping = True
|
| 182 |
+
break
|
|
|
|
|
|
|
|
|
|
| 183 |
else:
|
| 184 |
busy_processes += 1
|
| 185 |
logger.info("--- Process Used. Total Queued: {}. Total Used: {}".format(queued_processes, busy_processes))
|