Skip to content

Commit 3ed14e4

Browse files
committed
Fixed None exception
1 parent 413ea86 commit 3ed14e4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

redis/asyncio/multidb/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ async def _check_databases_health(
280280
if on_error:
281281
on_error(result.original_exception)
282282

283-
async def _check_db_health(self, database: AsyncDatabase,) -> bool:
283+
async def _check_db_health(self, database: AsyncDatabase) -> bool:
284284
"""
285285
Runs health checks on the given database until first failure.
286286
"""
@@ -307,7 +307,8 @@ def _on_circuit_state_change_callback(self, circuit: CircuitBreaker, old_state:
307307
loop.call_later(DEFAULT_GRACE_PERIOD, _half_open_circuit, circuit)
308308

309309
async def aclose(self):
310-
await self.command_executor.active_database.client.aclose()
310+
if self.command_executor.active_database:
311+
await self.command_executor.active_database.client.aclose()
311312

312313
def _half_open_circuit(circuit: CircuitBreaker):
313314
circuit.state = CBState.HALF_OPEN

tests/test_asyncio/test_scenario/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ async def r_multi_db(request) -> AsyncGenerator[tuple[MultiDBClient, CheckActive
9595
async def teardown():
9696
await client.aclose()
9797

98-
if isinstance(client.command_executor.active_database.client, Redis):
98+
if (
99+
client.command_executor.active_database
100+
and isinstance(client.command_executor.active_database.client, Redis)
101+
):
99102
await client.command_executor.active_database.client.connection_pool.disconnect()
100103

101104
await asyncio.sleep(10)

0 commit comments

Comments
 (0)