From 99536f84fbe06a1beb36b10ee7882ab8efe27141 Mon Sep 17 00:00:00 2001 From: Edi Feschiyan Date: Tue, 14 Jul 2020 12:42:36 +0300 Subject: When using asyncio.timeout on a response() task it will return None If not caught when that happens, it will raise TypeErrors and random unawaited coros/tasks --- pyagl/services/base.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyagl/services/base.py b/pyagl/services/base.py index 766a51b..e34d89c 100644 --- a/pyagl/services/base.py +++ b/pyagl/services/base.py @@ -238,9 +238,15 @@ class AGLBaseService: self.logger.error("Unhandled seal: " + str(e)) async def afbresponse(self): - resp = await self.response() - if resp is not None: - return AFBResponse(resp) + resp = None + try: + resp = await self.response() + resp = AFBResponse(resp) + except TypeError as v: # on asyncio.timeout()-ed response will return None and AFBResponse() will + # raise an error, catch it. probably more appropriate to handle it in AFBResponse() + self.logger.warning("Something probably timedout on response(), just tried to parse None to AFBResponse()") + + return resp async def request(self, verb: str, values: Union[str, dict] = "", msgid: int = None, api=None): msgid = next(newrand()) if msgid is None else msgid -- cgit