← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/wait-for-child-process into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/wait-for-child-process into lp:maas.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~jtv/maas/wait-for-child-process/+merge/121390

In test_dns.py we fire up lots and lots of DNS daemons.  Cleanup of these daemons was deficient in two ways:

1. The processes were never reaped, resulting in dozens of zombie processes piling up over a test run.

2. No cleanup was attempted if an exception occurred too early in the setup code.  Probably inconsequential, but minimizing the window for failure before arranging for cleanup is a matter of principle.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/wait-for-child-process/+merge/121390
Your team MAAS Maintainers is requested to review the proposed merge of lp:~jtv/maas/wait-for-child-process into lp:maas.
=== modified file 'src/maastesting/bindfixture.py'
--- src/maastesting/bindfixture.py	2012-07-17 12:15:56 +0000
+++ src/maastesting/bindfixture.py	2012-08-27 09:35:23 +0000
@@ -208,6 +208,7 @@
                     stdout=log_file, stderr=log_file,
                     close_fds=True, cwd=self.config.homedir,
                     env=env, preexec_fn=preexec_fn)
+        self.addCleanup(self._stop)
         # Keep the log_file open for reading so that we can still get the log
         # even if the log is deleted.
         open_log_file = open(self.config.log_file, "rb")
@@ -246,7 +247,6 @@
             raise Exception(
                 "Timeout waiting for BIND server to start: log in %r." %
                 (self.config.log_file,))
-        self.addCleanup(self._stop)
 
     def _request_stop(self):
         outstr, errstr = self.rndc("stop")
@@ -258,15 +258,7 @@
     def _stop(self):
         """Stop the running server. Normally called by cleanups."""
         self._request_stop()
-        # Wait for the server to go down...
-        timeout = time.time() + 15
-        while time.time() < timeout:
-            if not self.is_server_running():
-                break
-            time.sleep(0.3)
-        else:
-            raise Exception(
-                "Timeout waiting for BIND server to go down.")
+        self.process.wait()
 
 
 class BINDServer(fixtures.Fixture):