Worker thread that processes tasks using a specific game worker.
(self, worker_id: int, task_queue: Queue)
| 224 | return (i, j, result) |
| 225 | |
| 226 | def _worker_thread(self, worker_id: int, task_queue: Queue): |
| 227 | """Worker thread that processes tasks using a specific game worker.""" |
| 228 | game_worker = self.game_pool[worker_id] |
| 229 | self.logger.debug(f"Worker {worker_id} started") |
| 230 | |
| 231 | while True: |
| 232 | try: |
| 233 | task = task_queue.get(timeout=1) # Short timeout to allow clean exit |
| 234 | except: |
| 235 | # Queue is empty and no more tasks coming |
| 236 | break |
| 237 | |
| 238 | try: |
| 239 | self._evaluate_matrix_cell_parallel(game_worker, **task) |
| 240 | except Exception as e: |
| 241 | self.logger.error(f"Worker {worker_id} failed on task {task}: {e}") |
| 242 | finally: |
| 243 | task_queue.task_done() |
| 244 | |
| 245 | self.logger.debug(f"Worker {worker_id} stopped") |
| 246 | |
| 247 | def _evaluate_matrix(self, player1_name: str, player2_name: str): |
| 248 | """Evaluate a matrix between two players using manual thread management.""" |
nothing calls this directly
no test coverage detected