← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~mbp/launchpad/882370-pidfile into lp:launchpad

 

Martin Pool has proposed merging lp:~mbp/launchpad/882370-pidfile into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #882370 in Launchpad itself: "racey test canonical/lazr/doc/pidfile.txt: "pid file was not removed""
  https://bugs.launchpad.net/launchpad/+bug/882370

For more details, see:
https://code.launchpad.net/~mbp/launchpad/882370-pidfile/+merge/80536

make another test perhaps less likely to fail because of timing issues, and perhaps more likely to explain what went wrong if it did fail

bug 882370
-- 
https://code.launchpad.net/~mbp/launchpad/882370-pidfile/+merge/80536
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/882370-pidfile into lp:launchpad.
=== modified file 'lib/canonical/lazr/doc/pidfile.txt'
--- lib/canonical/lazr/doc/pidfile.txt	2008-09-23 14:35:10 +0000
+++ lib/canonical/lazr/doc/pidfile.txt	2011-10-27 04:52:27 +0000
@@ -71,6 +71,7 @@
 or SIGTERM, too. We'll demonstrate this with a couple of functions, because
 we'll need them again later.
 
+    >>> import errno
     >>> import time
     >>> subprocess_code = '''
     ... import time
@@ -92,13 +93,21 @@
     ...
     >>> def stop(pid, sig):
     ...     os.kill(pid, sig)
-    ...     for i in range(20):
+    ...     for i in range(300):
     ...         if not os.path.exists(pidfile_path('nuts')):
     ...             print 'Stopped successfully'
     ...             break
     ...         time.sleep(0.1)
     ...     else:
-    ...         print 'Error: pid file was not removed'
+    ...         try:
+    ...             # Is it still here at all?
+    ...             os.kill(pid, 0)
+    ...         except OSError, e:
+    ...             if e.errno == errno.ESRCH:
+    ...                 print 'Error: pid file was not removed'
+    ...             else: raise
+    ...         else:
+    ...             print 'Error: process did not exit'
     ...
 
 Here's our example.  We start, and then stop with SIGINT.