Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

fix socket.error raises #1129

Merged
merged 16 commits into from Nov 29, 2021
10 changes: 10 additions & 0 deletions aioredis/connection.py
Expand Up @@ -52,6 +52,16 @@
ssl.SSLError: 2,
}

# In Python 2.7 a socket.error is raised for a nonblocking read.
# The _compat module aliases BlockingIOError to socket.error to be
# Python 2/3 compatible.
# However this means that all socket.error exceptions need to be handled
# properly within these exception handlers.
# We need to make sure socket.error is included in these handlers and
# provide a dummy error number that will never match a real exception.
if socket.error not in NONBLOCKING_EXCEPTION_ERROR_NUMBERS:
NONBLOCKING_EXCEPTION_ERROR_NUMBERS[socket.error] = -999999

NONBLOCKING_EXCEPTIONS = tuple(NONBLOCKING_EXCEPTION_ERROR_NUMBERS.keys())

try:
Expand Down