diff options
author | Louis-Dominique Dubeau <ldd@lddubeau.com> | 2017-01-03 10:19:48 -0500 |
---|---|---|
committer | Louis-Dominique Dubeau <ldd@lddubeau.com> | 2018-07-12 16:29:41 -0400 |
commit | 1e62bef251d834e9a2830d608377449b6540f804 (patch) | |
tree | a1745a454bda3850372f56920b1f90202642a3fa /redis/_compat.py | |
parent | 413e802f8fe390738bc1e89716083586e0269fd0 (diff) | |
download | redis-py-1e62bef251d834e9a2830d608377449b6540f804.tar.gz |
InterruptedError does not exist in Python < 3.3.
Remove InterruptedError in favor of using select.error. Support for the
2.7 series requires this because InterruptedError was not introduced
until Python 3.3.
Diffstat (limited to 'redis/_compat.py')
-rw-r--r-- | redis/_compat.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/redis/_compat.py b/redis/_compat.py index 307f3cc..26ee348 100644 --- a/redis/_compat.py +++ b/redis/_compat.py @@ -2,11 +2,6 @@ import errno import sys -try: - InterruptedError = InterruptedError -except: - InterruptedError = OSError - # For Python older than 3.5, retry EINTR. if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 5): @@ -15,16 +10,14 @@ if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and import time import errno - from select import select as _select + 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 InterruptedError as e: - # Python 2 does not define InterruptedError, instead - # try to catch an OSError with errno == EINTR == 4. - if getattr(e, 'errno', None) == getattr(errno, 'EINTR', 4): + except select_error as e: + if e.args[0] == errno.EINTR: continue raise |