[Checkins] SVN: zc.sshtunnel/trunk/src/zc/sshtunnel/recipe.py clean up the pid file when the opportunity presents itself

Fred L. Drake, Jr. fdrake at gmail.com
Tue Feb 27 11:35:04 EST 2007


Log message for revision 72884:
  clean up the pid file when the opportunity presents itself

Changed:
  U   zc.sshtunnel/trunk/src/zc/sshtunnel/recipe.py

-=-
Modified: zc.sshtunnel/trunk/src/zc/sshtunnel/recipe.py
===================================================================
--- zc.sshtunnel/trunk/src/zc/sshtunnel/recipe.py	2007-02-27 16:25:49 UTC (rev 72883)
+++ zc.sshtunnel/trunk/src/zc/sshtunnel/recipe.py	2007-02-27 16:35:02 UTC (rev 72884)
@@ -120,7 +120,17 @@
             try:
                 os.kill(pid, 0)
             except OSError, v:
-                print v
+                if v.errno == errno.ESRCH:
+                    print name, 'not running'
+                    # Unlink the pid_file if we can, to avoid having
+                    # process numbers cycle around and accidentally
+                    # recognizing some other process mistakenly.
+                    try:
+                        os.unlink(pid_file)
+                    except OSError:
+                        pass
+                else:
+                    print v
             else:
                 print name, 'running'
         else:



More information about the Checkins mailing list