fix circular import errors so the server and start again
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from server.GameBoard import GameBoard
|
||||
from typing import TYPE_CHECKING
|
||||
import inspect, pickle
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from server.GameBoard import GameBoard
|
||||
|
||||
class RedisGameBoardStore:
|
||||
def __init__(self, redis_url:str="redis://localhost:6379/0", key_prefix:str="snake:gameboard", ttl_seconds:int=900, **kwargs):
|
||||
self.redis_url = redis_url
|
||||
@@ -23,7 +26,7 @@ class RedisGameBoardStore:
|
||||
def _key(self, game_id:str) -> str:
|
||||
return f"{self.key_prefix}:{game_id}"
|
||||
|
||||
async def save(self, game_id:str, game_board:GameBoard) -> None:
|
||||
async def save(self, game_id:str, game_board:'GameBoard') -> None:
|
||||
redis = await self._get_redis()
|
||||
payload = pickle.dumps(game_board, protocol=pickle.HIGHEST_PROTOCOL)
|
||||
await redis.set(self._key(game_id), payload, ex=self.ttl_seconds)
|
||||
|
||||
Reference in New Issue
Block a user