File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -52,11 +52,21 @@ async def ping(self) -> bool:
5252 return self ._could_connect
5353
5454 async def _health_task (self ) -> None :
55- while True :
56- previous = self .could_connect
57- await self .ping ()
58-
59- if not previous and self .could_connect :
60- logger .info ("Redis connection has been (re)established: %s" , self .url )
61-
62- await asyncio .sleep (5 )
55+ try :
56+ while True :
57+ previous = self .could_connect
58+ await self .ping ()
59+
60+ if not previous and self .could_connect :
61+ logger .info ("Redis connection has been (re)established: %s" , self .url )
62+
63+ await asyncio .sleep (5 )
64+ except asyncio .CancelledError :
65+ logger .warning (
66+ 'Redis connection: "%s" health check was cancelled. Safe to ignore on shutdown. '
67+ "If this was not intentional, all middleware relying on this connection will now be in-memory." ,
68+ self .url ,
69+ )
70+ self ._could_connect = False
71+ finally :
72+ await self .pool .aclose ()
You can’t perform that action at this time.
0 commit comments