File "sharpy-sc2/python-sc2/sc2/main.py", line 608, in run_game
result = asyncio.get_event_loop().run_until_complete(_host_game(map_settings, players, **kwargs))
File "/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "sharpy-sc2/python-sc2/sc2/main.py", line 488, in _host_game
await client.save_replay(save_replay_as)
File "sharpy-sc2/python-sc2/sc2/client.py", line 117, in save_replay
result = await self._execute(save_replay=sc_pb.RequestSaveReplay())
File "sharpy-sc2/python-sc2/sc2/protocol.py", line 75, in _execute
raise ProtocolError(f"{response.error}")
sc2.protocol.ProtocolError: ['Not in a game']
Seems like if the saving of a replay were done not in sc2.main._host_game_aiter but instead added to sc2.client.leave that might solve it? That way when a bot calls client.leave, the save happens before await self._execute(leave_game=sc_pb.RequestLeaveGame())
When trying to
client.leave()
in a bot:Seems like if the saving of a replay were done not in
sc2.main._host_game_aiter
but instead added tosc2.client.leave
that might solve it? That way when a bot calls client.leave, the save happens beforeawait self._execute(leave_game=sc_pb.RequestLeaveGame())
https://github.com/BurnySc2/python-sc2/blob/b54fbb869da8b4442b4fb41996f62d16434b9a93/sc2/main.py#L520-L524
https://github.com/BurnySc2/python-sc2/blob/b54fbb869da8b4442b4fb41996f62d16434b9a93/sc2/client.py#L100-L113