Skip to content

Commit

Permalink
fix socket.error raises
Browse files Browse the repository at this point in the history
  • Loading branch information
x0day committed Sep 16, 2021
1 parent d9519df commit fb6c366
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aioredis/connection.py
Original file line number Diff line number Diff line change
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

0 comments on commit fb6c366

Please sign in to comment.