Closed FriendsOfGalaxy closed 5 years ago
Hey,
currently every time check_game_statuses method runs it will update the status of every game. Even if it didn't change.
async def check_game_statuses(self): self.updating_game_statuses = True for local_game in await self.get_local_games(): self.update_local_game_status(local_game) await asyncio.sleep(5) self.updating_game_statuses = False
This results in
2019-10-09 11:50:04,774 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=18, local_game_state=<LocalGameState.Installed: 1>)} 2019-10-09 11:50:04,775 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,775 - root - DEBUG - Task manager notification client: creating task 143 (drain) 2019-10-09 11:50:04,776 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=11, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,776 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,776 - root - DEBUG - Task manager notification client: creating task 144 (drain) 2019-10-09 11:50:04,777 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=9, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,777 - root - DEBUG - Sending 123 byte of data 2019-10-09 11:50:04,778 - root - DEBUG - Task manager notification client: creating task 145 (drain) 2019-10-09 11:50:04,778 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=10, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,779 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,779 - root - DEBUG - Task manager notification client: creating task 146 (drain) 2019-10-09 11:50:04,780 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=26, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,780 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,780 - root - DEBUG - Task manager notification client: creating task 147 (drain) 2019-10-09 11:50:04,781 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=27, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,781 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,782 - root - DEBUG - Task manager notification client: creating task 148 (drain) 2019-10-09 11:50:04,782 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=23, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,783 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,783 - root - DEBUG - Task manager notification client: creating task 149 (drain) 2019-10-09 11:50:04,783 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=13, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:04,784 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:04,784 - root - DEBUG - Task manager notification client: creating task 150 (drain) 2019-10-09 11:50:04,785 - root - DEBUG - Task manager notification client: finished task 143 (drain) 2019-10-09 11:50:04,785 - root - DEBUG - Task manager notification client: finished task 144 (drain) 2019-10-09 11:50:04,786 - root - DEBUG - Task manager notification client: finished task 145 (drain) 2019-10-09 11:50:04,786 - root - DEBUG - Task manager notification client: finished task 146 (drain) 2019-10-09 11:50:04,786 - root - DEBUG - Task manager notification client: finished task 147 (drain) 2019-10-09 11:50:04,787 - root - DEBUG - Task manager notification client: finished task 148 (drain) 2019-10-09 11:50:04,787 - root - DEBUG - Task manager notification client: finished task 149 (drain) 2019-10-09 11:50:04,788 - root - DEBUG - Task manager notification client: finished task 150 (drain) 2019-10-09 11:50:08,739 - root - DEBUG - Received 55 bytes of data 2019-10-09 11:50:08,739 - root - INFO - Handling request: id=26, method=ping, params={} 2019-10-09 11:50:08,740 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "26", "result": null} 2019-10-09 11:50:08,740 - root - DEBUG - Task manager jsonrpc server: creating task 32 (drain) 2019-10-09 11:50:08,741 - root - DEBUG - Task manager jsonrpc server: finished task 32 (drain) 2019-10-09 11:50:10,774 - root - DEBUG - Checking local game statuses... 2019-10-09 11:50:10,775 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID gta5 is not installed. 2019-10-09 11:50:10,776 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID lanoire is not installed. 2019-10-09 11:50:10,776 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID mp3 is not installed. 2019-10-09 11:50:10,777 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID gta3 is not installed. 2019-10-09 11:50:10,777 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID gtavc is not installed. 2019-10-09 11:50:10,777 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID bully is not installed. 2019-10-09 11:50:10,778 - root - DEBUG - ROCKSTAR_GAME_NOT_INSTALLED: The game with ID rdr2 is not installed. 2019-10-09 11:50:10,778 - root - DEBUG - ROCKSTAR_INSTALLED_GAMES: [LocalGame(game_id=18, local_game_state=<LocalGameState.Installed: 1>), LocalGame(game_id=11, local_gamestate=<LocalGameState.None: 0>), LocalGame(game_id=9, local_gamestate=<LocalGameState.None: 0>), LocalGame(game_id=10, local_gamestate=<LocalGameState.None: 0>), LocalGame(game_id=26, local_gamestate=<LocalGameState.None: 0>), LocalGame(game_id=27, local_gamestate=<LocalGameState.None: 0>), LocalGame(game_id=23, local_gamestate=<LocalGameState.None: 0>), LocalGame(game_id=13, local_gamestate=<LocalGameState.None: 0>)] 2019-10-09 11:50:10,779 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=18, local_game_state=<LocalGameState.Installed: 1>)} 2019-10-09 11:50:10,779 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:10,780 - root - DEBUG - Task manager notification client: creating task 151 (drain) 2019-10-09 11:50:10,780 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=11, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,781 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:10,781 - root - DEBUG - Task manager notification client: creating task 152 (drain) 2019-10-09 11:50:10,782 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=9, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,782 - root - DEBUG - Sending 123 byte of data 2019-10-09 11:50:10,783 - root - DEBUG - Task manager notification client: creating task 153 (drain) 2019-10-09 11:50:10,783 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=10, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,784 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:10,784 - root - DEBUG - Task manager notification client: creating task 154 (drain) 2019-10-09 11:50:10,784 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=26, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,785 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:10,785 - root - DEBUG - Task manager notification client: creating task 155 (drain) 2019-10-09 11:50:10,786 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=27, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,786 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:10,787 - root - DEBUG - Task manager notification client: creating task 156 (drain) 2019-10-09 11:50:10,787 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=23, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,788 - root - DEBUG - Sending 124 byte of data 2019-10-09 11:50:10,788 - root - DEBUG - Task manager notification client: creating task 157 (drain) 2019-10-09 11:50:10,788 - root - INFO - Sending notification: method=local_game_status_changed, params={'local_game': LocalGame(game_id=13, local_gamestate=<LocalGameState.None: 0>)} 2019-10-09 11:50:10,789 - root - DEBUG - Sending 124 byte of data
lots of local_game_status_changed notifications being called every 5 seconds. I think it could be mitigated by keeping cache of game installation status and then sending notification only when it actually changed.
This issue has been fixed with commit https://github.com/tylerbrawl/Galaxy-Plugin-Rockstar/commit/77403e8fd880325e06e724d831ede2c28f81d554.
Hey,
currently every time check_game_statuses method runs it will update the status of every game. Even if it didn't change.
This results in
lots of local_game_status_changed notifications being called every 5 seconds. I think it could be mitigated by keeping cache of game installation status and then sending notification only when it actually changed.