From 592f0a770842a5e11da157099c35b5fa7af1c9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bourdeauducq?= Date: Thu, 28 Nov 2024 18:55:19 +0800 Subject: [PATCH] afws_client: sync --- artiq/frontend/afws_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/artiq/frontend/afws_client.py b/artiq/frontend/afws_client.py index 50c3de832..01e7c3b20 100755 --- a/artiq/frontend/afws_client.py +++ b/artiq/frontend/afws_client.py @@ -79,13 +79,16 @@ class Client: self.writer.write((" ".join(command) + "\n").encode()) async def read_line(self): - return (await self.reader.readline()).decode("ascii") + line = (await self.reader.readline()).decode("ascii") + if not line and self.reader.at_eof(): + raise ConnectionError("connection was closed unexpectedly") + return line async def read_reply(self): - return (await self.reader.readline()).decode("ascii").split() + return (await self.read_line()).split() async def read_json(self): - return json.loads((await self.reader.readline()).decode("ascii")) + return json.loads((await self.read_line())) async def login(self, username, password): await self.send_command("LOGIN", username, password)