From 9296821d6d11715fe48a89b6def94447957277e6 Mon Sep 17 00:00:00 2001 From: Jonney <603073+Jonney@users.noreply.github.com> Date: Mon, 27 Jan 2025 23:16:12 +0800 Subject: [PATCH 1/2] except asyncio.IncompleteReadError insteed of ConnectionError According to the asyncio documentation (https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamReader.readexactly), readexactly() will raise asyncio.IncompleteReadError, not ConnectionError. If asyncio.IncompleteReadError is not caught, we will get "Task exception was never retrieved." --- pytoniq/liteclient/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytoniq/liteclient/client.py b/pytoniq/liteclient/client.py index 9884c65..a7845d2 100644 --- a/pytoniq/liteclient/client.py +++ b/pytoniq/liteclient/client.py @@ -142,7 +142,7 @@ async def send_and_encrypt(self, data: bytes, qid: str) -> asyncio.Future: async def receive(self, data_len: int) -> bytes: try: data = await self.reader.readexactly(data_len) - except ConnectionError: + except asyncio.IncompleteReadError: await self.close() raise return data From c65ef3542748858e4197ae30616e67147c27bfae Mon Sep 17 00:00:00 2001 From: Jonney <603073+Jonney@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:11:40 +0800 Subject: [PATCH 2/2] ConnectionError is also necessary. ConnectionError is also necessary. --- pytoniq/liteclient/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytoniq/liteclient/client.py b/pytoniq/liteclient/client.py index a7845d2..99e7095 100644 --- a/pytoniq/liteclient/client.py +++ b/pytoniq/liteclient/client.py @@ -142,7 +142,7 @@ async def send_and_encrypt(self, data: bytes, qid: str) -> asyncio.Future: async def receive(self, data_len: int) -> bytes: try: data = await self.reader.readexactly(data_len) - except asyncio.IncompleteReadError: + except (ConnectionError|asyncio.IncompleteReadError): await self.close() raise return data