Hello community,

here is the log from the commit of package python-pymemcache for 
openSUSE:Factory checked in at 2020-05-12 22:33:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pymemcache (Old)
 and      /work/SRC/openSUSE:Factory/.python-pymemcache.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pymemcache"

Tue May 12 22:33:02 2020 rev:8 rq:802871 version:3.1.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pymemcache/python-pymemcache.changes      
2020-04-23 18:35:07.428625642 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pymemcache.new.2738/python-pymemcache.changes
    2020-05-12 22:33:13.511981204 +0200
@@ -1,0 +2,7 @@
+Tue May 12 08:26:33 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 3.1.0:
+  * Add TLS support for TCP sockets.
+  * Fix corner case when dead hashed server comes back alive.
+
+-------------------------------------------------------------------

Old:
----
  pymemcache-3.0.1.tar.gz

New:
----
  pymemcache-3.1.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pymemcache.spec ++++++
--- /var/tmp/diff_new_pack.GT1BTq/_old  2020-05-12 22:33:14.167982573 +0200
+++ /var/tmp/diff_new_pack.GT1BTq/_new  2020-05-12 22:33:14.171982581 +0200
@@ -20,7 +20,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %bcond_without python2
 Name:           python-pymemcache
-Version:        3.0.1
+Version:        3.1.0
 Release:        0
 Summary:        A pure Python memcached client
 License:        Apache-2.0

++++++ pymemcache-3.0.1.tar.gz -> pymemcache-3.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/ChangeLog.rst 
new/pymemcache-3.1.0/ChangeLog.rst
--- old/pymemcache-3.0.1/ChangeLog.rst  2020-03-20 18:05:35.000000000 +0100
+++ new/pymemcache-3.1.0/ChangeLog.rst  2020-04-09 18:11:32.000000000 +0200
@@ -1,6 +1,11 @@
 Changelog
 =========
 
+New in version 3.1.0
+--------------------
+* Add TLS support for TCP sockets.
+* Fix corner case when dead hashed server comes back alive.
+
 New in version 3.0.1
 --------------------
 * Make MockMemcacheClient more consistent with the real client.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/PKG-INFO 
new/pymemcache-3.1.0/PKG-INFO
--- old/pymemcache-3.0.1/PKG-INFO       2020-03-20 18:06:20.000000000 +0100
+++ new/pymemcache-3.1.0/PKG-INFO       2020-04-09 18:13:42.000000000 +0200
@@ -1,10 +1,10 @@
 Metadata-Version: 2.1
 Name: pymemcache
-Version: 3.0.1
+Version: 3.1.0
 Summary: "A comprehensive, fast, pure Python memcached client"
 Home-page: https://github.com/pinterest/pymemcache
-Author: Charles Gordon
-Author-email: [email protected]
+Author: Jon Parise
+Author-email: [email protected]
 License: Apache License 2.0
 Description: pymemcache
         ==========
@@ -133,6 +133,7 @@
         * `Jon Parise <https://github.com/jparise>`_
         * `Stephen Rosen <https://github.com/sirosen>`_
         * `Feras Alazzeh <https://github.com/FerasAlazzeh>`_
+        * `Moisés Guimarães de Medeiros <https://github.com/moisesguimaraes>`_
         
         We're Hiring!
         =============
@@ -142,6 +143,11 @@
         Changelog
         =========
         
+        New in version 3.1.0
+        --------------------
+        * Add TLS support for TCP sockets.
+        * Fix corner case when dead hashed server comes back alive.
+        
         New in version 3.0.1
         --------------------
         * Make MockMemcacheClient more consistent with the real client.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/README.rst 
new/pymemcache-3.1.0/README.rst
--- old/pymemcache-3.0.1/README.rst     2020-01-15 23:00:22.000000000 +0100
+++ new/pymemcache-3.1.0/README.rst     2020-04-09 18:11:32.000000000 +0200
@@ -125,6 +125,7 @@
 * `Jon Parise <https://github.com/jparise>`_
 * `Stephen Rosen <https://github.com/sirosen>`_
 * `Feras Alazzeh <https://github.com/FerasAlazzeh>`_
+* `Moisés Guimarães de Medeiros <https://github.com/moisesguimaraes>`_
 
 We're Hiring!
 =============
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache/__init__.py 
new/pymemcache-3.1.0/pymemcache/__init__.py
--- old/pymemcache-3.0.1/pymemcache/__init__.py 2020-03-20 18:05:35.000000000 
+0100
+++ new/pymemcache-3.1.0/pymemcache/__init__.py 2020-04-09 18:11:32.000000000 
+0200
@@ -1,4 +1,4 @@
-__version__ = '3.0.1'
+__version__ = '3.1.0'
 
 from pymemcache.client.base import Client  # noqa
 from pymemcache.client.base import PooledClient  # noqa
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache/client/base.py 
new/pymemcache-3.1.0/pymemcache/client/base.py
--- old/pymemcache-3.0.1/pymemcache/client/base.py      2020-03-20 
16:29:34.000000000 +0100
+++ new/pymemcache-3.1.0/pymemcache/client/base.py      2020-04-07 
17:40:36.000000000 +0200
@@ -219,7 +219,8 @@
                  key_prefix=b'',
                  default_noreply=True,
                  allow_unicode_keys=False,
-                 encoding='ascii'):
+                 encoding='ascii',
+                 tls_context=None):
         """
         Constructor.
 
@@ -269,6 +270,7 @@
         self.default_noreply = default_noreply
         self.allow_unicode_keys = allow_unicode_keys
         self.encoding = encoding
+        self.tls_context = tls_context
 
     def check_key(self, key):
         """Checks key and add key_prefix."""
@@ -281,6 +283,11 @@
         if isinstance(self.server, (list, tuple)):
             sock = self.socket_module.socket(self.socket_module.AF_INET,
                                              self.socket_module.SOCK_STREAM)
+
+            if self.tls_context:
+                sock = self.tls_context.wrap_socket(
+                    sock, server_hostname=self.server[0]
+                )
         else:
             sock = self.socket_module.socket(self.socket_module.AF_UNIX,
                                              self.socket_module.SOCK_STREAM)
@@ -291,6 +298,7 @@
             if self.no_delay and sock.family == self.socket_module.AF_INET:
                 sock.setsockopt(self.socket_module.IPPROTO_TCP,
                                 self.socket_module.TCP_NODELAY, 1)
+
         except Exception:
             sock.close()
             raise
@@ -1016,7 +1024,8 @@
                  lock_generator=None,
                  default_noreply=True,
                  allow_unicode_keys=False,
-                 encoding='ascii'):
+                 encoding='ascii',
+                 tls_context=None):
         self.server = server
         self.serde = serde or LegacyWrappingSerde(serializer, deserializer)
         self.connect_timeout = connect_timeout
@@ -1037,6 +1046,7 @@
             max_size=max_pool_size,
             lock_generator=lock_generator)
         self.encoding = encoding
+        self.tls_context = tls_context
 
     def check_key(self, key):
         """Checks key and add key_prefix."""
@@ -1055,7 +1065,8 @@
                         socket_module=self.socket_module,
                         key_prefix=self.key_prefix,
                         default_noreply=self.default_noreply,
-                        allow_unicode_keys=self.allow_unicode_keys)
+                        allow_unicode_keys=self.allow_unicode_keys,
+                        tls_context=self.tls_context)
         return client
 
     def close(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache/client/hash.py 
new/pymemcache-3.1.0/pymemcache/client/hash.py
--- old/pymemcache-3.0.1/pymemcache/client/hash.py      2020-03-20 
16:29:34.000000000 +0100
+++ new/pymemcache-3.1.0/pymemcache/client/hash.py      2020-04-07 
17:40:36.000000000 +0200
@@ -36,7 +36,8 @@
         ignore_exc=False,
         allow_unicode_keys=False,
         default_noreply=True,
-        encoding='ascii'
+        encoding='ascii',
+        tls_context=None
     ):
         """
         Constructor.
@@ -87,7 +88,8 @@
             'deserializer': deserializer,
             'allow_unicode_keys': allow_unicode_keys,
             'default_noreply': default_noreply,
-            'encoding': encoding
+            'encoding': encoding,
+            'tls_context': tls_context,
         }
 
         if use_pooling is True:
@@ -99,6 +101,7 @@
         for server, port in servers:
             self.add_server(server, port)
         self.encoding = encoding
+        self.tls_context = tls_context
 
     def add_server(self, server, port):
         key = '%s:%s' % (server, port)
@@ -121,22 +124,28 @@
         key = '%s:%s' % (server, port)
         self.hasher.remove_node(key)
 
+    def _retry_dead(self):
+        current_time = time.time()
+        ldc = self._last_dead_check_time
+        # We have reached the retry timeout
+        if current_time - ldc > self.dead_timeout:
+            candidates = []
+            for server, dead_time in self._dead_clients.items():
+                if current_time - dead_time > self.dead_timeout:
+                    candidates.append(server)
+            for server in candidates:
+                logger.debug(
+                    'bringing server back into rotation %s',
+                    server
+                )
+                self.add_server(*server)
+                del self._dead_clients[server]
+            self._last_dead_check_time = current_time
+
     def _get_client(self, key):
         check_key_helper(key, self.allow_unicode_keys, self.key_prefix)
-        if len(self._dead_clients) > 0:
-            current_time = time.time()
-            ldc = self._last_dead_check_time
-            # we have dead clients and we have reached the
-            # timeout retry
-            if current_time - ldc > self.dead_timeout:
-                for server, dead_time in self._dead_clients.items():
-                    if current_time - dead_time > self.dead_timeout:
-                        logger.debug(
-                            'bringing server back into rotation %s',
-                            server
-                        )
-                        self.add_server(*server)
-                        self._last_dead_check_time = current_time
+        if self._dead_clients:
+            self._retry_dead()
 
         server = self.hasher.get_node(key)
         # We've ran out of servers to try
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache/test/conftest.py 
new/pymemcache-3.1.0/pymemcache/test/conftest.py
--- old/pymemcache-3.0.1/pymemcache/test/conftest.py    2019-01-08 
16:29:27.000000000 +0100
+++ new/pymemcache-3.1.0/pymemcache/test/conftest.py    2020-04-07 
17:40:36.000000000 +0200
@@ -1,5 +1,6 @@
 import pytest
 import socket
+import ssl
 
 
 def pytest_addoption(parser):
@@ -9,6 +10,12 @@
     parser.addoption('--port', action='store', default='11211',
                      help='memcached server port')
 
+    parser.addoption('--tls-server', action='store', default='localhost',
+                     help='TLS memcached server')
+
+    parser.addoption('--tls-port', action='store', default='11212',
+                     help='TLS memcached server port')
+
     parser.addoption('--size', action='store', default=1024,
                      help='size of data in benchmarks')
 
@@ -30,6 +37,16 @@
 
 
 @pytest.fixture(scope='session')
+def tls_host(request):
+    return request.config.option.tls_server
+
+
[email protected](scope='session')
+def tls_port(request):
+    return int(request.config.option.tls_port)
+
+
[email protected](scope='session')
 def size(request):
     return int(request.config.option.size)
 
@@ -49,6 +66,13 @@
     return {'pymemcache_test:%d' % i: 'X' * size for i in range(keys)}
 
 
[email protected](scope='session')
+def tls_context():
+    return ssl.create_default_context(
+        cafile="extras/tls/ca-root.crt"
+    )
+
+
 def pytest_generate_tests(metafunc):
     if 'socket_module' in metafunc.fixturenames:
         socket_modules = [socket]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache/test/test_client_hash.py 
new/pymemcache-3.1.0/pymemcache/test/test_client_hash.py
--- old/pymemcache-3.0.1/pymemcache/test/test_client_hash.py    2020-03-20 
16:29:34.000000000 +0100
+++ new/pymemcache-3.1.0/pymemcache/test/test_client_hash.py    2020-04-07 
17:40:36.000000000 +0200
@@ -295,4 +295,42 @@
         for client in hash_client.clients.values():
             assert client.encoding == encoding
 
+    @mock.patch("pymemcache.client.hash.Client")
+    def test_dead_server_comes_back(self, client_patch):
+        client = HashClient([], dead_timeout=0, retry_attempts=0)
+        client.add_server("127.0.0.1", 11211)
+
+        test_client = client_patch.return_value
+        test_client.server = ("127.0.0.1", 11211)
+
+        test_client.get.side_effect = socket.timeout()
+        with pytest.raises(socket.timeout):
+            client.get(b"key", noreply=False)
+        # Client gets removed because of socket timeout
+        assert ("127.0.0.1", 11211) in client._dead_clients
+
+        test_client.get.side_effect = lambda *_: "Some value"
+        # Client should be retried and brought back
+        assert client.get(b"key") == "Some value"
+        assert ("127.0.0.1", 11211) not in client._dead_clients
+
+    @mock.patch("pymemcache.client.hash.Client")
+    def test_failed_is_retried(self, client_patch):
+        client = HashClient([], retry_attempts=1, retry_timeout=0)
+        client.add_server("127.0.0.1", 11211)
+
+        assert client_patch.call_count == 1
+
+        test_client = client_patch.return_value
+        test_client.server = ("127.0.0.1", 11211)
+
+        test_client.get.side_effect = socket.timeout()
+        with pytest.raises(socket.timeout):
+            client.get(b"key", noreply=False)
+
+        test_client.get.side_effect = lambda *_: "Some value"
+        assert client.get(b"key") == "Some value"
+
+        assert client_patch.call_count == 1
+
     # TODO: Test failover logic
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache/test/test_integration.py 
new/pymemcache-3.1.0/pymemcache/test/test_integration.py
--- old/pymemcache-3.0.1/pymemcache/test/test_integration.py    2020-01-02 
22:28:28.000000000 +0100
+++ new/pymemcache-3.1.0/pymemcache/test/test_integration.py    2020-04-07 
17:40:36.000000000 +0200
@@ -362,3 +362,19 @@
 
     with pytest.raises(MemcacheClientError):
         _unicode_value_in_set()
+
+
[email protected]()
+def test_tls(client_class, tls_host, tls_port, socket_module, tls_context):
+    client = client_class(
+        (tls_host, tls_port),
+        socket_module=socket_module,
+        tls_context=tls_context
+    )
+    client.flush_all()
+
+    key = b'key'
+    value = b'value'
+    key2 = b'key2'
+    value2 = b'value2'
+    get_set_helper(client, key, value, key2, value2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/pymemcache.egg-info/PKG-INFO 
new/pymemcache-3.1.0/pymemcache.egg-info/PKG-INFO
--- old/pymemcache-3.0.1/pymemcache.egg-info/PKG-INFO   2020-03-20 
18:06:20.000000000 +0100
+++ new/pymemcache-3.1.0/pymemcache.egg-info/PKG-INFO   2020-04-09 
18:13:42.000000000 +0200
@@ -1,10 +1,10 @@
 Metadata-Version: 2.1
 Name: pymemcache
-Version: 3.0.1
+Version: 3.1.0
 Summary: "A comprehensive, fast, pure Python memcached client"
 Home-page: https://github.com/pinterest/pymemcache
-Author: Charles Gordon
-Author-email: [email protected]
+Author: Jon Parise
+Author-email: [email protected]
 License: Apache License 2.0
 Description: pymemcache
         ==========
@@ -133,6 +133,7 @@
         * `Jon Parise <https://github.com/jparise>`_
         * `Stephen Rosen <https://github.com/sirosen>`_
         * `Feras Alazzeh <https://github.com/FerasAlazzeh>`_
+        * `Moisés Guimarães de Medeiros <https://github.com/moisesguimaraes>`_
         
         We're Hiring!
         =============
@@ -142,6 +143,11 @@
         Changelog
         =========
         
+        New in version 3.1.0
+        --------------------
+        * Add TLS support for TCP sockets.
+        * Fix corner case when dead hashed server comes back alive.
+        
         New in version 3.0.1
         --------------------
         * Make MockMemcacheClient more consistent with the real client.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pymemcache-3.0.1/setup.cfg 
new/pymemcache-3.1.0/setup.cfg
--- old/pymemcache-3.0.1/setup.cfg      2020-03-20 18:06:20.000000000 +0100
+++ new/pymemcache-3.1.0/setup.cfg      2020-04-09 18:13:42.000000000 +0200
@@ -1,8 +1,8 @@
 [metadata]
 name = pymemcache
 version = attr: pymemcache.__version__
-author = Charles Gordon
-author_email = [email protected]
+author = Jon Parise
+author_email = [email protected]
 description = "A comprehensive, fast, pure Python memcached client"
 long_description = file: README.rst, ChangeLog.rst
 long_description_content_type = text/x-rst


Reply via email to