@@ -1028,7 +1028,7 @@ def can_get_connection(self) -> bool:
1028
1028
1029
1029
async def get_connection (self , command_name , * keys , ** options ):
1030
1030
"""Get a connected connection from the pool"""
1031
- connection = self .get_available_connection ()
1031
+ connection = await self .get_available_connection ()
1032
1032
try :
1033
1033
await self .ensure_connection (connection )
1034
1034
except BaseException :
@@ -1037,7 +1037,7 @@ async def get_connection(self, command_name, *keys, **options):
1037
1037
1038
1038
return connection
1039
1039
1040
- def get_available_connection (self ):
1040
+ async def get_available_connection (self ):
1041
1041
"""Get a connection from the pool, without making sure it is connected"""
1042
1042
try :
1043
1043
connection = self ._available_connections .pop ()
@@ -1167,24 +1167,16 @@ def __init__(
1167
1167
self ._condition = asyncio .Condition ()
1168
1168
self .timeout = timeout
1169
1169
1170
- async def get_connection (self , command_name , * keys , ** options ):
1170
+ async def get_available_connection (self ):
1171
1171
"""Gets a connection from the pool, blocking until one is available"""
1172
1172
try :
1173
1173
async with self ._condition :
1174
1174
async with async_timeout (self .timeout ):
1175
1175
await self ._condition .wait_for (self .can_get_connection )
1176
- connection = super ().get_available_connection ()
1176
+ return await super ().get_available_connection ()
1177
1177
except asyncio .TimeoutError as err :
1178
1178
raise ConnectionError ("No connection available." ) from err
1179
1179
1180
- # We now perform the connection check outside of the lock.
1181
- try :
1182
- await self .ensure_connection (connection )
1183
- return connection
1184
- except BaseException :
1185
- await self .release (connection )
1186
- raise
1187
-
1188
1180
async def release (self , connection : AbstractConnection ):
1189
1181
"""Releases the connection back to the pool."""
1190
1182
async with self ._condition :
0 commit comments