[rhmessaging-commits] rhmessaging commits: r2140 - mgmt/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Jun 5 19:02:58 EDT 2008


Author: nunofsantos
Date: 2008-06-05 19:02:57 -0400 (Thu, 05 Jun 2008)
New Revision: 2140

Modified:
   mgmt/mint/python/mint/__init__.py
Log:
additional locking around idMap

Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py	2008-06-05 22:30:30 UTC (rev 2139)
+++ mgmt/mint/python/mint/__init__.py	2008-06-05 23:02:57 UTC (rev 2140)
@@ -7,6 +7,7 @@
 from sqlobject import *
 from threading import Lock
 from traceback import print_exc
+from sys import exc_info
 
 from mint import schema
 
@@ -124,7 +125,11 @@
     self.lock = Lock()
 
   def set(self, idOriginal, obj):
-    self.idMap[idOriginal] = obj
+    self.lock.acquire()
+    try:
+      self.idMap[idOriginal] = obj
+    finally:
+      self.lock.release()
 
   def getByOriginalId(self, objType, idOriginal, managedBroker, create=False, args={}):
     obj = None
@@ -505,7 +510,7 @@
   def updateObjWithDict(self, obj, d):
     updateDone = False
     reattemptCount = 0
-    while not updateDone:
+    while not updateDone and len(d) > 0:
       try:
         obj.set(**d)
         obj.syncUpdate()
@@ -531,6 +536,11 @@
       except KeyError, detail:
         self.log("KeyError: Schema mismatch: %s" % detail)
         return None
+      except:
+        #TODO: better exception handling here
+        self.log("Unexpected Error: %s" % sys.exc_info()[0])
+        print "Unexpected Error: %s" % sys.exc_info()[0]
+        return obj
     return obj
 
   def methodCallback(self, brokerId, methodId, errorNo, errorText, args):




More information about the rhmessaging-commits mailing list