Skip to content

Commit

Permalink
Enabled multithreading properly on client_runner
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanAEckelberg committed Jan 8, 2024
1 parent 11e1d25 commit abff18e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion server/client_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ def external_runner(self) -> None:
self.index_to_seed_id[index] = gameboard['game_board']['seed']

# then run them in parallel using their index as a unique identifier
[self.jobqueues[i % 6].put(self.internal_runner(games[i], i)) for i in range(self.total_number_of_games)]
[self.jobqueues[i % 6].put((self.internal_runner, games[i], i)) for i in range(self.total_number_of_games)]
threads: list[threading.Thread] = [
threading.Thread(target=runner_utils.worker_main, args=(self.jobqueues[i],)) for i in range(6)]
[t.start() for t in threads]
[t.join() for t in threads if t.is_alive()]
self.read_best_logs_and_insert()
self.delete_runner_temp()
Expand Down
2 changes: 1 addition & 1 deletion server/runner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
def worker_main(jobqueue: Queue):
while not jobqueue.empty():
job_func = jobqueue.get()
job_func()
job_func[0](job_func[1:])
jobqueue.task_done()

0 comments on commit abff18e

Please sign in to comment.