[Nym3-commit] r409 - in trunk: . nymbaron/Client

laurent at conuropsis.org laurent at conuropsis.org
Wed Nov 16 20:37:27 CET 2005


Author: laurent
Date: 2005-11-16 20:37:26 +0100 (Wed, 16 Nov 2005)
New Revision: 409

Modified:
   trunk/TODO
   trunk/nymbaron/Client/Account.py
Log:
Complete the fix for the locking issue.


Modified: trunk/TODO
===================================================================
--- trunk/TODO	2005-11-16 19:27:30 UTC (rev 408)
+++ trunk/TODO	2005-11-16 19:37:26 UTC (rev 409)
@@ -13,7 +13,7 @@
  * let the user set the domainname of the account when known.
  . do not return silently without giving explanation of what went wrong or what
    was done
- . don't fail miserably when another instance holds a lock, instead simply
+ o don't fail miserably when another instance holds a lock, instead simply
    wait for it a few times [client]
  o display the username in list-accounts [client]
  o clarify the "localpart" thing in nymbarond(8) [doc]

Modified: trunk/nymbaron/Client/Account.py
===================================================================
--- trunk/nymbaron/Client/Account.py	2005-11-16 19:27:30 UTC (rev 408)
+++ trunk/nymbaron/Client/Account.py	2005-11-16 19:37:26 UTC (rev 409)
@@ -66,8 +66,18 @@
     def _lock(self):
         """Lock the tagmap file"""
         self.lock = mixminion.Common.Lockfile(self.filename + '.lck')
-        self.lock.acquire(blocking = 1)
+	nbtries = 5
+	while True:
+	    try:
+		self.lock.acquire(blocking = 0)
+		break
+	    except:
+		import time
+		time.sleep(2)
+		nbtries = nbtries - 1
+		if nbtries == 0: raise Exception("Unable to acquire lock")
 
+
     def _release(self):
         self.lock.release()
 	self.lock = None
@@ -286,7 +296,16 @@
 	"""Locks the user. For well behaved functions."""
 	self.lock = mixminion.Common.Lockfile(self.config.path + os.sep + \
 		    self.idTag + '.lck')
-	self.lock.acquire(blocking = 1)
+	nbtries = 5
+	while True:
+	    try:
+		self.lock.acquire(blocking = 0)
+		break
+	    except:
+		import time
+		time.sleep(2)
+		nbtries = nbtries - 1
+		if nbtries == 0: raise Exception("Unable to acquire lock")
 
     def _release(self):
 	"""Releases the lock"""



More information about the Nym3-commit mailing list