|
13 | 13 |
|
14 | 14 | from ..async_utils import cancel_wait_task |
15 | 15 | from ..background_task import periodic |
16 | | -from ..logging_utils import log_catch |
| 16 | +from ..logging_utils import log_catch, log_context |
17 | 17 | from ._constants import ( |
18 | 18 | DEFAULT_DECODE_RESPONSES, |
19 | 19 | DEFAULT_HEALTH_CHECK_INTERVAL, |
@@ -77,16 +77,20 @@ async def _periodic_check_health() -> None: |
77 | 77 | ) |
78 | 78 |
|
79 | 79 | async def shutdown(self) -> None: |
80 | | - if self._health_check_task: |
81 | | - assert self._health_check_task_started_event # nosec |
82 | | - await self._health_check_task_started_event.wait() # NOTE: wait for the health check task to have started once before we can cancel it |
83 | | - await cancel_wait_task(self._health_check_task) |
| 80 | + with log_context( |
| 81 | + _logger, level=logging.DEBUG, msg=f"Shutdown RedisClientSDK {self}" |
| 82 | + ): |
| 83 | + if self._health_check_task: |
| 84 | + assert self._health_check_task_started_event # nosec |
| 85 | + # NOTE: wait for the health check task to have started once before we can cancel it |
| 86 | + await self._health_check_task_started_event.wait() |
| 87 | + await cancel_wait_task(self._health_check_task, max_delay=3) |
84 | 88 |
|
85 | | - await self._client.aclose(close_connection_pool=True) |
| 89 | + await self._client.aclose(close_connection_pool=True) |
86 | 90 |
|
87 | 91 | async def ping(self) -> bool: |
88 | 92 | with log_catch(_logger, reraise=False): |
89 | | - # FIXME: this ping should NOT retry!? |
| 93 | + # NOTE: retry_* input parameters from aioredis.from_url do not apply for the ping call |
90 | 94 | await self._client.ping() |
91 | 95 | return True |
92 | 96 | return False |
|
0 commit comments