launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27686
[Merge] ~jugmac00/launchpad:replace-python-memcached-with-pymemcache into launchpad:master
Jürgen Gmach has proposed merging ~jugmac00/launchpad:replace-python-memcached-with-pymemcache into launchpad:master.
Commit message:
Replace unmaintained python-memcached with pymemcache
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/411523
This is work in progress.
Trigger the "Connection refused" issue with running
bin/test -vcct test_memcache_client
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:replace-python-memcached-with-pymemcache into launchpad:master.
diff --git a/lib/lp/services/memcache/client.py b/lib/lp/services/memcache/client.py
index a672c99..1adb0f5 100644
--- a/lib/lp/services/memcache/client.py
+++ b/lib/lp/services/memcache/client.py
@@ -9,21 +9,29 @@ __all__ = [
import re
-import memcache
-
from lp.services.config import config
def memcache_client_factory(timeline=True):
- """Return a memcache.Client for Launchpad."""
+ """Return a pymemcache Client for Launchpad."""
servers = [
(host, int(weight)) for host, weight in re.findall(
r'\((.+?),(\d+)\)', config.memcache.servers)]
assert len(servers) > 0, "Invalid memcached server list %r" % (
config.memcache.servers,)
+ # even without any custom code I get a connection refused
+ from pymemcache.client.base import Client
+ return Client(["127.0.0.1", 11242])
+ # both in the lxd container and on my host pymemcache works as expected
+ # with the system memcached running on 11211
+
+ # what also worked here, within pdb
+ # from memcache import Client
+ # return Client(["127.0.0.1:11242"])
+
if timeline:
from lp.services.memcache.timeline import TimelineRecordingClient
client_factory = TimelineRecordingClient
else:
- client_factory = memcache.Client
+ client_factory = Client
return client_factory(servers)
diff --git a/lib/lp/services/memcache/timeline.py b/lib/lp/services/memcache/timeline.py
index 0e898f8..1ec4d2a 100644
--- a/lib/lp/services/memcache/timeline.py
+++ b/lib/lp/services/memcache/timeline.py
@@ -10,13 +10,13 @@ __all__ = [
import logging
from lazr.restful.utils import get_current_browser_request
-import memcache
+from pymemcache.client.base import Client
from lp.services import features
from lp.services.timeline.requesttimeline import get_request_timeline
-class TimelineRecordingClient(memcache.Client):
+class TimelineRecordingClient(Client):
def __get_timeline_action(self, suffix, key):
request = get_current_browser_request()
@@ -36,17 +36,16 @@ class TimelineRecordingClient(memcache.Client):
return None
action = self.__get_timeline_action("get", key)
try:
- return memcache.Client.get(self, key)
+ return Client.get(self, key)
finally:
action.finish()
- def set(self, key, value, time=0, min_compress_len=0):
+ def set(self, key, value, time=0):
if not self._enabled:
return None
action = self.__get_timeline_action("set", key)
try:
- success = memcache.Client.set(self, key, value, time=time,
- min_compress_len=min_compress_len)
+ success = Client.set(self, key, value, expire=time)
if success:
logging.debug("Memcache set succeeded for %s", key)
else:
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index 0e6ff1e..9da8e98 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -119,6 +119,7 @@ pygpgme==0.3+lp1
PyHamcrest==1.9.0
pyinotify==0.9.4
pymacaroons==0.13.0
+pymemcache==3.5.0
PyNaCl==1.3.0
pyOpenSSL==17.5.0
pystache==0.5.3
diff --git a/setup.cfg b/setup.cfg
index 70efbe9..da40348 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -70,6 +70,7 @@ install_requires =
pygettextpo
pygpgme
pymacaroons
+ pymemcache
pystache
python-debian
python-keystoneclient
References