[or-cvs] r17053: {weather} Fix locking in poll.py too. Mostly trivial, except for the i (weather/trunk)

pde at seul.org pde at seul.org
Thu Oct 9 06:13:30 UTC 2008


Author: pde
Date: 2008-10-09 02:13:30 -0400 (Thu, 09 Oct 2008)
New Revision: 17053

Modified:
   weather/trunk/poll.py
Log:
Fix locking in poll.py too.  Mostly trivial, except for the inverted
release/acquire bit.



Modified: weather/trunk/poll.py
===================================================================
--- weather/trunk/poll.py	2008-10-09 06:03:26 UTC (rev 17052)
+++ weather/trunk/poll.py	2008-10-09 06:13:30 UTC (rev 17053)
@@ -14,7 +14,6 @@
 from config import authenticator, URLbase, weather_email, failure_threshold
 from config import poll_period, ping_targets, weather_storage
 from weather import parse_subscriptions
-from weather import safeRelease
 
 # Lets debug this
 import traceback
@@ -162,12 +161,14 @@
           # anymore
           if self.subscriptions[node] != "":
             self.gdbm_lock.release()
-            self.ping(node)       # this is time consuming ; don't hold the lock
-            self.gdbm_lock.acquire()
+            try:
+              self.ping(node)       # this is time consuming ; don't hold the lock
+            finally:
+              self.gdbm_lock.acquire()
           node = self.subscriptions.nextkey(node)
 
     finally:
-        safeRelease(self.gdbm_lock)
+        self.gdbm_lock.release()
 
     #del self.tp   # this minimises the chance of confusion a local tor control
                   # port crash with a remote node being down
@@ -235,11 +236,11 @@
     # envelope header.
     s = smtplib.SMTP()
     s.connect()
+    self.gdbm_lock.acquire()
     try:
-        self.gdbm_lock.acquire()
         list = parse_subscriptions(node,self.subscriptions)
     finally:
-        safeRelease(self.gdbm_lock)
+        self.gdbm_lock.release()
     for address, unsub_token in list:
  
       unsub_url = URLbase+"/unsubscribe/" + unsub_token



More information about the tor-commits mailing list