Skip to content

Commit

Permalink
Changed iteritems() to items() in fetch_all_worker_data()
Browse files Browse the repository at this point in the history
The size of the list would still be changing while iterating over the dictionary as worker creation is now asynchronous. items() creates a copy of the dictionary, which I think we should use for now. Note that items() in python 3 changes to an iterator.
  • Loading branch information
Unknown committed Sep 20, 2018
1 parent 5cf5f59 commit 9c1a35a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aimmo-game/simulation/worker_managers/worker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def get_code(self, player_id):
return self._data.get_code(player_id)

def fetch_all_worker_data(self, player_id_to_game_state):
for player_id, worker in self.player_id_to_worker.iteritems():
# Work with the current copy of the list, as the size of the dictionary is changing
for player_id, worker in self.player_id_to_worker.items():
worker.fetch_data(player_id_to_game_state[player_id])

def get_player_id_to_serialised_actions(self):
Expand Down

0 comments on commit 9c1a35a

Please sign in to comment.