summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdi Feschiyan <edi.feschiyan@konsulko.com>2020-07-14 12:42:36 +0300
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2020-07-14 12:42:36 +0300
commit99536f84fbe06a1beb36b10ee7882ab8efe27141 (patch)
treebf1c1a22fd8886b7a5a0a645007179f2f7e1651a
parent8d93b3beae86f6947645ce537bfac108c355d0b4 (diff)
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
-rw-r--r--pyagl/services/base.py12
1 files 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