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
1diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
2index 541ef56..ebd1f96 100644
3--- a/lib/lp/testing/layers.py
4+++ b/lib/lp/testing/layers.py
5@@ -607,6 +607,15 @@ class MemcachedLayer(BaseLayer):
6 if not BaseLayer.persist_test_services:
7 # Kill our memcached, and there is no reason to be nice about it.
8 kill_by_pidfile(MemcachedLayer.getPidFile())
9+ # Also try killing the subprocess just in case it's different
10+ # from what's recorded in the pid file, to avoid deadlocking on
11+ # wait().
12+ try:
13+ MemcachedLayer._memcached_process.kill()
14+ except OSError:
15+ pass
16+ # Clean up the resulting zombie.
17+ MemcachedLayer._memcached_process.wait()
18 MemcachedLayer._memcached_process = None
19
20 @classmethod

Subscribers

People subscribed via source and target branches

to status/vote changes: