Skip to content

Commit 0776b14

Browse files
author
Chris Rossi
authored
fix: retry connection errors with memcache (#645)
The most common transient error with memcache is `ConnectionResetError`, which wasn't included in exceptions to retry. Now all connection errors are retried. Fixes #620
1 parent cb8ecf0 commit 0776b14

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/google-cloud-ndb/google/cloud/ndb/global_cache.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
import pymemcache
2828
import redis as redis_module
2929

30+
# Python 2.7 doesn't have ConnectionError. In Python 3, ConnectionError is subclass of
31+
# OSError, which Python 2.7 does have.
32+
ConnectionError = getattr(__builtins__, "ConnectionError", OSError)
33+
3034

3135
class GlobalCache(object):
3236
"""Abstract base class for a global entity cache.
@@ -275,6 +279,8 @@ class RedisCache(GlobalCache):
275279
"""
276280

277281
transient_errors = (
282+
IOError,
283+
ConnectionError,
278284
redis.exceptions.ConnectionError,
279285
redis.exceptions.TimeoutError,
280286
)
@@ -452,6 +458,7 @@ class MemcacheCache(GlobalCache):
452458

453459
transient_errors = (
454460
IOError,
461+
ConnectionError,
455462
pymemcache.exceptions.MemcacheServerError,
456463
pymemcache.exceptions.MemcacheUnexpectedCloseError,
457464
)

0 commit comments

Comments
 (0)