Merge "memcache: Prevent possible pool exhaustion"

This commit is contained in:
Zuul 2021-12-20 22:23:51 +00:00 committed by Gerrit Code Review
commit 270b8da1a0

View File

@ -153,10 +153,18 @@ class MemcacheConnPool(Pool):
def get(self):
fp, sock = super(MemcacheConnPool, self).get()
if fp is None:
# An error happened previously, so we need a new connection
fp, sock = self.create()
return fp, sock
try:
if fp is None:
# An error happened previously, so we need a new connection
fp, sock = self.create()
return fp, sock
except MemcachePoolTimeout:
# This is the only place that knows an item was successfully taken
# from the pool, so it has to be responsible for repopulating it.
# Any other errors should get handled in _get_conns(); see the
# comment about timeouts during create() there.
self.put((None, None))
raise
class MemcacheRing(object):