launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27159
[Merge] ~cjwatson/launchpad:improve-memcached-teardown into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:improve-memcached-teardown into launchpad:master.
Commit message:
Clean up MemcachedLayer subprocess properly
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/403388
The MemcachedLayer teardown procedure left a zombie process lying around, resulting in a ResourceWarning on Python >= 3.6. Go to some more effort to clean this up.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:improve-memcached-teardown into launchpad:master.
diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
index 541ef56..ebd1f96 100644
--- a/lib/lp/testing/layers.py
+++ b/lib/lp/testing/layers.py
@@ -607,6 +607,15 @@ class MemcachedLayer(BaseLayer):
if not BaseLayer.persist_test_services:
# Kill our memcached, and there is no reason to be nice about it.
kill_by_pidfile(MemcachedLayer.getPidFile())
+ # Also try killing the subprocess just in case it's different
+ # from what's recorded in the pid file, to avoid deadlocking on
+ # wait().
+ try:
+ MemcachedLayer._memcached_process.kill()
+ except OSError:
+ pass
+ # Clean up the resulting zombie.
+ MemcachedLayer._memcached_process.wait()
MemcachedLayer._memcached_process = None
@classmethod