Closed
Description
Version: 4.2.2
Platform: Windows 11
Description: The methods send_packed_command
and read_response
on the asyncio.connection.Connection
class
have exception handlers which catch BaseException
and call self.disconnect()
before re-raising.
This is rather unfortunate, because it makes it impossible to use an outer Timeout
around redis methods. For example, the following pattern fails:
async def get_next_message_or_None():
async with async_timeout.timeout(0.9) as self.timeout_manager:
# blocking method to return messages
async for message in self.pubsub.listen():
return message
This is because internally, the timeout will raise a CancelledError
in the task. This is a base exception and isn't converted into a TimeoutError until higher in the call stack.
Generally, BaseExceptions should not be caught. In this case, it would be prudent to change this to catch Exception
instead.
Metadata
Metadata
Assignees
Labels
No labels