diff options
author | Jordan Carlson <jwgcarlson@gmail.com> | 2021-06-01 20:39:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 20:39:14 -0700 |
commit | b164be9bf3c053b76d58f19eacfe7ff7cac1ca9b (patch) | |
tree | 99d68f3aadee86f4526cf5d54cc0405bb23beeee /pymemcache/client/base.py | |
parent | dd61d9f0878adba8692b49167f9a80af4de2f8c2 (diff) | |
download | pymemcache-b164be9bf3c053b76d58f19eacfe7ff7cac1ca9b.tar.gz |
Remove idle connections from pool (#309)
The Memcached server can be configured to drop idle connections (via the
idle_timeout option). When this occurs, pymemcache may still try to
use the connection, resulting in MemcacheUnexpectedCloseError. Hence
the need for client-side idle timeout logic.
Diffstat (limited to 'pymemcache/client/base.py')
-rw-r--r-- | pymemcache/client/base.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pymemcache/client/base.py b/pymemcache/client/base.py index 4db03b8..a0816cf 100644 --- a/pymemcache/client/base.py +++ b/pymemcache/client/base.py @@ -1039,6 +1039,9 @@ class PooledClient(object): max_pool_size: maximum pool size to use (going above this amount triggers a runtime error), by default this is 2147483648L when not provided (or none). + pool_idle_timeout: pooled connections are discarded if they have been + unused for this many seconds. A value of 0 indicates + that pooled connections are never discarded. lock_generator: a callback/type that takes no arguments that will be called to create a lock or semaphore that can protect the pool from concurrent access (for example a @@ -1065,6 +1068,7 @@ class PooledClient(object): socket_module=socket, key_prefix=b'', max_pool_size=None, + pool_idle_timeout=0, lock_generator=None, default_noreply=True, allow_unicode_keys=False, @@ -1088,6 +1092,7 @@ class PooledClient(object): self._create_client, after_remove=lambda client: client.close(), max_size=max_pool_size, + idle_timeout=pool_idle_timeout, lock_generator=lock_generator) self.encoding = encoding self.tls_context = tls_context |