summaryrefslogtreecommitdiff
path: root/redis/connection.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Move the username argument in the Redis and Connection classes to the endAndy McCurdy2020-01-311-6/+5
| | | | | | | This helps those poor souls that specify all their connection options as non-keyword arguments. Fixes #1276
* Provide AUTH fallback support for connection URLs with a username componentAndy McCurdy2020-01-311-1/+15
| | | | | | | | | | | | | Prior to ACL support, redis-py ignored the username component of Connection URLs. With ACL support, usernames are no longer ignored and are used to authenticate against an ACL rule. Some cloud vendors with managed Redis instances (like Heroku) provide connection URLs with a username component pre-ACL that is not intended to be used. Sending that username to Redis servers < 6.0.0 results in an error. Attempt to detect this condition and retry the AUTH command with only the password such that authentication continues to work for these users. Fixes #1274
* better thread-safety for ConnectionPool (#1270)Andy McCurdy2020-01-301-43/+120
| | | Better thread and fork safety for ConnectionPool and BlockingConnectionPool
* Slight optimization to command packing.Andy McCurdy2019-12-291-3/+4
| | | | Fixed #1255
* Added the 'ssl_check_hostname' option.Andy McCurdy2019-12-291-2/+5
| | | | | | | | 'ssl_check_hostname' tells SSL Connections to whether to require the TCP hostname to match the hostname specified in the SSL Cert. By default 'ssl_check_hostname' is False to maintain backwards compatibility. Fixed #1196
* more accurate description of acceptable argument typesAndy McCurdy2019-12-291-2/+2
| | | | fixes #1214
* Allow setting client_name during connection construction.Peter van Dijk2019-12-291-15/+31
| | | | | | Client instances and Connection pools now accept "client_name" as an optional argument. If supplied, all connections created will be named via CLIENT SETNAME once the connection to the server is established.
* Added support for ACL commandsAndy McCurdy2019-12-281-14/+27
|
* Fix simple typo: recurrsion -> recursionTim Gates2019-12-071-1/+1
| | | | Closes #1252
* Add equality test on Redis client and conn pool (#1240)Rajiv Bakulesh Shah2019-11-111-0/+6
| | | Add equality test on Redis client and connection pool
* Version 3.3.93.3.9Zac Bristow2019-10-101-5/+7
| | | | | | | | | Fixes SSL read timeouts in Python 2.7 The ssl module in Python 2.7 raises timeouts as ssl.SSLError instead of socket.timeout. When these timeouts are encountered, the error will be re-raised as socket.timeout so it is handled appropriately by the connection.
* version 3.3.7, Fixed a socket.error regression introduced in 3.3.03.3.7Andy McCurdy2019-08-131-4/+16
| | | | | | | Prior versions of 3.3.x could potentially raise a raw socket.error (or one of its subclasses) instead of a redis.exceptions.ConnectionError. Fixes #1202
* version 3.3.6, fixed a regression in 3.3.5 with pubsub timeouts3.3.6Andy McCurdy2019-08-061-0/+8
| | | | Fixes #1200
* version 3.3.5, handle socket.timeout errors correctly in Python 2.73.3.5Andy McCurdy2019-08-021-16/+8
| | | | | Fix an issue where socket.timeout errors could be handled by the wrong exception handler in Python 2.7.
* version 3.3.4, more specifically identify nonblocking read errors3.3.4Andy McCurdy2019-07-301-1/+2
| | | | | | | versions 3.3.1, 3.3.2 and 3.3.3 could potentially hide ConnectionErrors on Python 2.7. This change accurately identifies errors by both exception class and errno to determine whether a nonblocking socket can be read
* version 3.3.4, more specifically identify nonblocking read errorsAndy McCurdy2019-07-301-14/+17
| | | | | | | versions 3.3.1, 3.3.2 and 3.3.3 could potentially hide ConnectionErrors on Python 2.7. This change accurately identifies errors by both exception class and errno to determine whether a nonblocking socket can be read
* Version 3.3.3. Accomodate Python 2.7.x versions < 2.7.9.3.3.3Andy McCurdy2019-07-301-2/+2
| | | | | | | | The SSL module includes in Python versions < 2.7.9 does not include the SSLWantReadError or SSLWantWriteError exceptions. As such we can't assume they are present just because the ssl module happens to be installed. Fixes #1197
* Version 3.3.2, SSL Blocking Exceptions don't use errno.EWOULDBLOCK3.3.2Andy McCurdy2019-07-291-3/+4
| | | | Ref #1197
* version 3.3.1, fixed a regression involving SSL and non-blocking sockets3.3.1Andy McCurdy2019-07-291-8/+19
| | | | Fixes #1197
* PING/PONG health checksAndy McCurdy2019-07-281-14/+47
| | | | | | | | | | | | | | | | | | | | | | The `Redis` class and the `ConnectionPool` class now support the "health_check_interval=N" option. By default N=0, which turns off health checks. `N` should be an integer, and when greater than 0, ensures that a health check is performed just before command execution anytime the underlying connection has been idle for more than N seconds. A health check is a full PING/PONG round trip to the Redis server. If a health check encounters a ConnectionError or TimeoutError, the connection is disconnected and reconnected and the health check is retried exactly once. Any error during the retry is raised to the caller. Health check retries are not governed by any other options such as `retry_on_timeout`. In systems where idle times are common, these health checks are the intended way to reconnect to the Redis server without harming any user data. When this option is enabled for PubSub connections, calling `get_message()` or `listen()` will send a health check anytime a message has not been read on the PubSub connection for `health_check_interval` seconds. Users should call `get_message()` or `listen()` at least every `health_check_interval` seconds in order to keep the connection open.
* Use nonblocking sockets instead of selectors for healthy connectionsAndy McCurdy2019-07-091-50/+105
| | | | | | | This replaces the work in 3.2.0 to use nonblocking sockets instead of selectors. Selectors proved to be problematic for some environments including eventlet and gevent. Nonblocking sockets should be available in all environments.
* All authentication-related errors now raise AuthenticationErrorAndy McCurdy2019-06-031-1/+4
| | | | | | | AuthenticationError is now a subclass of ConnectionError, which means the connection will be shut down and cleaned up. Fixes #923
* Pass encoding_errors setting to hiredis (>=1.0.0) (#1162)Brian Candler2019-05-291-0/+4
| | | | | Pass encoding_errors setting to hiredis (>=1.0.0). Fixes #1161
* remove Token class in favor of bytestringremove_tokenAndy McCurdy2019-05-281-46/+7
| | | | | | | The Token class was needed when supporting Python 2.6. Now that we've dropped support for 2.6, we don't need it anymore. Fixes #1066
* Merged the error process of "reading socket error" in two Parser class and ↵vic0202019-04-111-36/+31
| | | | | | | | added "host":"port" to Exception message for easy debug Change-Id: Ifaa3bef0c8daf3dd2c60b143746b75a26c182a88
* make sure the selector is instantiated prior to cleaning it upAndy McCurdy2019-03-181-2/+4
|
* Close the selector on disconnectBruce Merry2019-03-181-0/+2
|
* attempt to provide only healthy connections from the poolAndy McCurdy2019-02-041-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge pull request #1129 from Chronial/feature/fix-exceptAndy McCurdy2019-02-011-4/+4
|\ | | | | Do not leave connections in invalid state
| * Do not leave connections in invalid stateChronial2019-01-301-4/+4
| |
* | Merge pull request #1130 from Junnplus/socket-patchAndy McCurdy2019-02-011-1/+1
|\ \ | | | | | | Use IPPROTO_TCP constant instead of SOL_TCP constant
| * | use IPPROTO_TCP constant instead of SOL_TCP constantjunnplus2019-01-311-1/+1
| |/
* | readd the connection destructorAndy McCurdy2019-02-011-0/+6
| | | | | | | | | | | | Since Connection.disconnect() now verifies that the current process owns the connection before shutting the socket down we can safely readd the destructor just to make sure things are really cleaned up
* | Improve how connection pools operate in forked/child proceeses.Andy McCurdy2019-01-311-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes a process with an active connection to Redis forks and creates child processes taht also want to talk to Redis. Prior to this change there were a number of potential conflicts that could cause this to fail. Retrieving a connection from the pool and releasing a connection back to the pool check the current proceeses PID. If it's different than the PID that created the pool, reset() is called to get a fresh set of connections for the current process. However in doing so, pool.disconnect() was caused which closes the file descriptors that the parent may still be using. Further when the available_connections and in_use_connections lists are reset, all of those connections inherited from the parent are GC'd and the connection's `__del__` was called, which also closed the socket and file descriptor. This change prevents pool.disconnect() from being called when a pid is changed. It also removes the `__del__` destructor from connections. Neither of these are necessary or practical. Child processes still reset() their copy of the pool when first accessed causing their own connections to be created. `ConnectionPool.disconnect()` now checks the current process ID so that a child or parent can't disconnect the other's connections. Additionally, `Connection.disconnect()` now checks the current process ID and only calls `socket.shutdown()` if `disconnect()` is called by the same process that created the connection. This allows for a child process that inherited a connection to call `Connection.disconnect()` and not shutdown the parent's copy of the socket. Fixes #863 Fixes #784 Fixes #732 Fixes #1085 Fixes #504
* | Merge branch 'pr/1108' into pythonparserAndy McCurdy2019-01-281-3/+1
|\ \ | |/ |/|
| * Make PythonParser's on_disconnect consistent withAlexey Popravka2019-01-031-3/+1
| | | | | | | | | | Hiredisparser and Connection — do not close socket on disconnect. Resolves #1085
* | Connection URLs must have a valid scheme.Andy McCurdy2019-01-271-2/+6
| | | | | | | | | | Fixes #969 Fixes #961
* | Merge pull request #1087 from oridistor/ssl_sniAndy McCurdy2019-01-271-5/+18
|\ \ | | | | | | Add support for SNI connection to Redis-py
| * | pycodestyle fixes to connection.pyRoey Prat2018-11-271-4/+5
| | |
| * | Made sure SSL SNI will not affect using redis-py in versions older than 2.7.9Ori Markovitch2018-11-261-9/+17
| | |
| * | Add SSL SNI supportDanni Moiseyev2018-11-261-5/+9
| | |
* | | Merge pull request #1043 from Siecje/reprAndy McCurdy2019-01-271-1/+1
|\ \ \ | |_|/ |/| | Fix ConnectionPool repr when using default values
| * | Fix ConnectionPool repr when using default valuesCody Scot2018-10-261-1/+1
| | |
* | | Remove unnecessary compat shim for 'bytes'Jon Dufresne2018-12-281-1/+1
| |/ |/| | | | | | | | | Both Python 2.7 & Python 3 have the types bytes. On Python 2.7, it is an alias for the type str, same as what was previously defined in _compat.py.
* | Add missing UnixDomainSocketConnection._buffer_cutoffJyrki Muukkonen2018-11-151-0/+1
| | | | | | | | | | | | | | | | Without this using `unix_socket_path` will fail: AttributeError: 'UnixDomainSocketConnection' object has no attribute '_buffer_cutoff' Fixes #1067
* | Merge pull request #1017 from u2mejc/issue-1016Andy McCurdy2018-11-141-2/+2
|\ \ | | | | | | Enforce ssl_cert_reqs='required' by default
| * | Enforce ssl_cert_reqs='required' by defaultJustin Clark2018-08-071-2/+2
| |/
* | Merge pull request #1055 from tzickel/pipeperfAndy McCurdy2018-11-141-8/+15
|\ \ | | | | | | Improve performence of transactions / pipeline requests which involve large chunks of data.
| * | Improve performence of transactions / pipeline requests which involve largetzickel2018-11-061-8/+15
| | | | | | | | | | | | chunks of data.
* | | use str() to encode int or long valuesAndy McCurdy2018-11-141-1/+4
| | | | | | | | | | | | | | | on python2.7, repr() on a long produces '123L', which is clearly not what we want