diff options
author | Carlton Gibson <carlton.gibson@noumenal.es> | 2016-06-10 21:24:13 +0200 |
---|---|---|
committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2016-06-10 21:24:13 +0200 |
commit | 36283e4b647c37a9b3b585a40081aead27cfadc9 (patch) | |
tree | c0c3800cc508e9b8f2d068581576c000e08f292c /redis/_compat.py | |
parent | 67f9adca849ff104ede2a1e79591fcfeac960262 (diff) | |
download | redis-py-36283e4b647c37a9b3b585a40081aead27cfadc9.tar.gz |
Retry `select` calls on `InterruptedError`
Ref #738
Diffstat (limited to 'redis/_compat.py')
-rw-r--r-- | redis/_compat.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/redis/_compat.py b/redis/_compat.py index c4a72d9..4713d01 100644 --- a/redis/_compat.py +++ b/redis/_compat.py @@ -9,6 +9,15 @@ if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and import time import errno + from select import select as _select + + def select(rlist, wlist, xlist, timeout): + while True: + try: + return _select(rlist, wlist, xlist, timeout) + except InterruptedError: + continue + # Wrapper for handling interruptable system calls. def _retryable_call(s, func, *args, **kwargs): # Some modules (SSL) use the _fileobject wrapper directly and @@ -54,6 +63,8 @@ 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) |