Merge ~cjwatson/launchpad:improve-memcached-teardown into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: de885d9eb97a2f7830a9d1b820dc5b64eb83feb1
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:improve-memcached-teardown
Merge into: launchpad:master
Diff against target: 20 lines (+9/-0)
1 file modified
lib/lp/testing/layers.py (+9/-0)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+403388@code.launchpad.net

Commit message

Clean up MemcachedLayer subprocess properly

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote (last edit ):

Looks good! Edited! Again!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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):
607 if not BaseLayer.persist_test_services:607 if not BaseLayer.persist_test_services:
608 # Kill our memcached, and there is no reason to be nice about it.608 # Kill our memcached, and there is no reason to be nice about it.
609 kill_by_pidfile(MemcachedLayer.getPidFile())609 kill_by_pidfile(MemcachedLayer.getPidFile())
610 # Also try killing the subprocess just in case it's different
611 # from what's recorded in the pid file, to avoid deadlocking on
612 # wait().
613 try:
614 MemcachedLayer._memcached_process.kill()
615 except OSError:
616 pass
617 # Clean up the resulting zombie.
618 MemcachedLayer._memcached_process.wait()
610 MemcachedLayer._memcached_process = None619 MemcachedLayer._memcached_process = None
611620
612 @classmethod621 @classmethod

Subscribers

People subscribed via source and target branches

to status/vote changes: