From 2314b931b558aee2ceaf8b2eefcd6633a180794f Mon Sep 17 00:00:00 2001 From: JIAKUNHAO <jiakunhao@star-rising.com> Date: Thu, 24 Nov 2022 17:21:42 +0800 Subject: [PATCH] ws --- app/utils/websocket_tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/utils/websocket_tool.py b/app/utils/websocket_tool.py index 44d6c9e..a10ec64 100644 --- a/app/utils/websocket_tool.py +++ b/app/utils/websocket_tool.py @@ -77,7 +77,8 @@ manager = WebsocketUtil() def write(id: str, ws: List): print(f"序列化对象{ws}") with open(f"{id}.pkl", "wb") as f: - wsdump = pickle.dump(ws, f) + pickle.dump(ws, f) + f.close() def read(id: str): @@ -85,5 +86,6 @@ def read(id: str): with open(f"{id}.pkl", "rb") as f: wss = pickle.load(f) print(wss) + f.close() print(f"反序列化对象{wss}") return wss \ No newline at end of file