From b620d0a39c49a77798dcee6992ee7ca05d0b313a Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 7 May 2022 19:37:53 +0200 Subject: [PATCH] fix(etebase_fastapi): fix crash on shutdown (#133) self.redis isn't None, it's actually unset, so accessing it results in an exception: ``` ERROR: Traceback (most recent call last): File "./.venv/lib/python3.9/site-packages/starlette/routing.py", line 624, in lifespan await receive() File "./.venv/lib/python3.9/site-packages/starlette/routing.py", line 521, in __aexit__ await self._router.shutdown() File "./.venv/lib/python3.9/site-packages/starlette/routing.py", line 608, in shutdown await handler() File "./etebase_fastapi/main.py", line 72, in on_shutdown await redisw.close() File "./etebase_fastapi/redis.py", line 18, in close if self.redis is not None: AttributeError: 'RedisWrapper' object has no attribute 'redis' ``` --- etebase_fastapi/redis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etebase_fastapi/redis.py b/etebase_fastapi/redis.py index 3735e36..60df6a4 100644 --- a/etebase_fastapi/redis.py +++ b/etebase_fastapi/redis.py @@ -15,7 +15,7 @@ class RedisWrapper: self.redis = await aioredis.create_redis_pool(self.redis_uri) async def close(self): - if self.redis is not None: + if hasattr(self, "redis"): self.redis.close() await self.redis.wait_closed()