From dd321ab6002bd5ff4041b02e84e6d227f51cea4e Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Sun, 12 Apr 2020 22:07:37 +0200 Subject: [PATCH] fix a couple small bugs --- server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 51223a3..2ad3c72 100644 --- a/server.py +++ b/server.py @@ -136,7 +136,8 @@ async def notify_mattserver_about_sessions() -> None: data: Dict[str, Dict[str, str]] = {} for sid, sess in active_sessions.items(): data[sid] = sess.to_dict() - await session.post(config.get("mattserver", "notify_url"), json=data) + async with session.post(config.get("mattserver", "notify_url"), json=data) as response: + print("Mattserver response", response) class NotReadyException(BaseException): @@ -343,7 +344,11 @@ async def telnet_server( data = await reader.read(128) if not data: break - data_str = data.decode("utf-8") + try: + data_str = data.decode("utf-8") + except UnicodeDecodeError as e: + print(e) + continue parts = data_str.rstrip().split(" ") print(parts)