[Pywikipedia-l] SVN: [4937] trunk/pywikipedia/wikipedia.py

filnik at svn.wikimedia.org filnik at svn.wikimedia.org
Fri Jan 25 14:13:06 UTC 2008


Revision: 4937
Author:   filnik
Date:     2008-01-25 14:13:06 +0000 (Fri, 25 Jan 2008)

Log Message:
-----------
Seems that the pid file sometimes is corrupt, usually not. By the way, I'm tire to get every day 5-7 email from crontab, it's time to 'fix it' with a try/except block

Modified Paths:
--------------
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-01-24 22:36:12 UTC (rev 4936)
+++ trunk/pywikipedia/wikipedia.py	2008-01-25 14:13:06 UTC (rev 4937)
@@ -2767,9 +2767,16 @@
         else:
             now = time.time()
             for line in f.readlines():
-                line = line.split(' ')
-                pid = int(line[0])
-                ptime = int(line[1].split('.')[0])
+                try:
+                    line = line.split(' ')
+                    pid = int(line[0])
+                    ptime = int(line[1].split('.')[0])
+                except ValueError:
+                    # I go a lot of crontab errors because line is not a number.
+                    # Better to prevent that. If you find out the error, feel free
+                    # to fix it better.
+                    pid = 1
+                    ptime = time.time()
                 if now - ptime <= self.releasepid and pid != self.pid:
                     processes[pid] = ptime
         f = open(self.logfn(), 'w')





More information about the Pywikipedia-l mailing list