summaryrefslogtreecommitdiff
path: root/redis/__init__.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2014-05-27 13:03:45 -0700
committerAndy McCurdy <andy@andymccurdy.com>2014-05-27 13:03:45 -0700
commit0647659c2f3550063c404a616ba37987c9158149 (patch)
treed6e74ceb94f0fd1dd21ad558c655f3251f1e5978 /redis/__init__.py
parentc60536e5272ae6c410f61842f8c1581ebe83ca38 (diff)
downloadredis-py-0647659c2f3550063c404a616ba37987c9158149.tar.gz
Don't retry commands that fail due to a socket.timeout by default.
Users now have the ability about how socket.timeout errors are handled. Previously socket.timeout errors were handled just like any other socket error in that the command would be retried once. This createed a potential race condition when the client sends a command to a busy Redis server that can't reply faster than the client's `socket_timeout` option. In this case, the server will still eventually process the command. There's now a `retry_on_timeout` option that's set to False by default. If `retry_on_timeout` is False, any socket.timeout error will raise a TimeoutError exception. If `retry_on_timeout` is set to True, the client will retry executing the command once just like other socket.error exceptions. TODO: Write better tests for this code. TODO: Much of this logic could/should be moved to the ConnectionPool or Connection objects. Fixes #261
Diffstat (limited to 'redis/__init__.py')
-rw-r--r--redis/__init__.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/redis/__init__.py b/redis/__init__.py
index 2da66e2..cdfa1f2 100644
--- a/redis/__init__.py
+++ b/redis/__init__.py
@@ -9,15 +9,16 @@ from redis.connection import (
from redis.utils import from_url
from redis.exceptions import (
AuthenticationError,
- ConnectionError,
BusyLoadingError,
+ ConnectionError,
DataError,
InvalidResponse,
PubSubError,
+ ReadOnlyError,
RedisError,
ResponseError,
- WatchError,
- ReadOnlyError
+ TimeoutError,
+ WatchError
)
@@ -26,8 +27,8 @@ VERSION = tuple(map(int, __version__.split('.')))
__all__ = [
'Redis', 'StrictRedis', 'ConnectionPool', 'BlockingConnectionPool',
- 'Connection', 'SSLConnection', 'UnixDomainSocketConnection',
- 'RedisError', 'ConnectionError', 'ResponseError', 'AuthenticationError',
- 'InvalidResponse', 'DataError', 'PubSubError', 'WatchError', 'from_url',
- 'BusyLoadingError', 'ReadOnlyError'
+ 'Connection', 'SSLConnection', 'UnixDomainSocketConnection', 'from_url',
+ 'AuthenticationError', 'BusyLoadingError', 'ConnectionError', 'DataError',
+ 'InvalidResponse', 'PubSubError', 'ReadOnlyError', 'RedisError',
+ 'ResponseError', 'TimeoutError', 'WatchError'
]