Skip to content

Commit 92034cf

Browse files
authored
♻️ Close redis when request is done (#165)
1 parent d0d47e9 commit 92034cf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backend/app/api/deps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def get_redis() -> Generator["redis.Redis[Any]", None, None]:
3939

4040
redis_instance = redis.Redis(connection_pool=pool)
4141

42-
yield redis_instance
42+
try:
43+
yield redis_instance
44+
finally:
45+
redis_instance.close()
4346

4447

4548
RedisDep = Annotated["redis.Redis[Any]", Depends(get_redis)]

0 commit comments

Comments
 (0)