diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2019-02-04 17:44:39 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2019-02-04 17:45:27 -0800 |
commit | cfa2bc9b7ea860eb4a002eaa7029ecee01e39735 (patch) | |
tree | 9dc5d02bafeadb3278c6e58143454ffc27a7d3c8 /redis/_compat.py | |
parent | a4644592162afdfe5b8809fa28eff041f7be6993 (diff) | |
download | redis-py-cfa2bc9b7ea860eb4a002eaa7029ecee01e39735.tar.gz |
attempt to provide only healthy connections from the pool
Adds redis.selector, a module that provides the best selector strategy
available on the current platform. A redis.selector polls a socket to
provide two pieces of functionality:
1. Check whether data can be read from the socket. Prior versions of redis-py
provided this behavior with just select.select(). select() has lots of
limitations, most notably a limit of ~1024 file descriptors. Now that
better selectors are available, this should make can_read() faster and
able to accomodate more clients. See #1115 and #486
2. Check whether a socket is ready for a command to be sent. This doubles
as a health check. It ensures that the socket is available for writing,
has no data to read and has no known errors. Anytime a socket is
disconnected or hung up, data is available to be read, typically zero bytes.
ConnectionPool.get_connection has been modified to ensure that connections
it returns are connected and are ready for a command to be sent. If
get_connection encounters a case where a socket isn't ready for a command
the connection is reconnected and checked again.
TODO: more tests for this stuff. implement EPoll and KQueue selectors.
Fixes #1115
Fixes #486
Diffstat (limited to 'redis/_compat.py')
-rw-r--r-- | redis/_compat.py | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/redis/_compat.py b/redis/_compat.py index c9213a6..bde6fb6 100644 --- a/redis/_compat.py +++ b/redis/_compat.py @@ -9,17 +9,6 @@ if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and import socket import time - from select import select as _select, error as select_error - - def select(rlist, wlist, xlist, timeout): - while True: - try: - return _select(rlist, wlist, xlist, timeout) - except select_error as e: - if e.args[0] == errno.EINTR: - continue - raise - # Wrapper for handling interruptable system calls. def _retryable_call(s, func, *args, **kwargs): # Some modules (SSL) use the _fileobject wrapper directly and @@ -65,8 +54,6 @@ if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and return _retryable_call(sock, sock.recv_into, *args, **kwargs) else: # Python 3.5 and above automatically retry EINTR - from select import select - def recv(sock, *args, **kwargs): return sock.recv(*args, **kwargs) |