r5421 - in trunk: cumin/bin cumin/python/cumin sage/python/sage/wallaby

tmckay at fedoraproject.org tmckay at fedoraproject.org
Wed Jun 20 14:54:11 UTC 2012


Author: tmckay
Date: 2012-06-20 14:54:11 +0000 (Wed, 20 Jun 2012)
New Revision: 5421

Modified:
   trunk/cumin/bin/cumin-data
   trunk/cumin/bin/cumin-report
   trunk/cumin/bin/cumin-web
   trunk/cumin/python/cumin/util.py
   trunk/sage/python/sage/wallaby/wallabyoperations.py
Log:
Minor improvements to shutdown handling


Modified: trunk/cumin/bin/cumin-data
===================================================================
--- trunk/cumin/bin/cumin-data	2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/bin/cumin-data	2012-06-20 14:54:11 UTC (rev 5421)
@@ -308,6 +308,8 @@
     except:
         tm = 5
     t.join(tm)
+    if t.isAlive():
+        log.info("Shutdown thread timed out, exiting")
     if pipeThread:
         pipeThread.stop(immediate=True)
 

Modified: trunk/cumin/bin/cumin-report
===================================================================
--- trunk/cumin/bin/cumin-report	2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/bin/cumin-report	2012-06-20 14:54:11 UTC (rev 5421)
@@ -286,6 +286,8 @@
     except:
         tm = 5
     t.join(tm)
+    if t.isAlive():
+        log.info("Shutdown thread timed out, exiting")
     if pipeThread:
         pipeThread.stop(immediate=True)
     return adjust_return(passed_init, return_code)

Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web	2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/bin/cumin-web	2012-06-20 14:54:11 UTC (rev 5421)
@@ -321,6 +321,8 @@
     except:
         tm = 5
     t.join(tm)
+    if t.isAlive():
+        log.info("Shutdown thread timed out, exiting")
     if pipeThread:
         pipeThread.stop(immediate=True)
     return adjust_return(passed_init, return_code)

Modified: trunk/cumin/python/cumin/util.py
===================================================================
--- trunk/cumin/python/cumin/util.py	2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/python/cumin/util.py	2012-06-20 14:54:11 UTC (rev 5421)
@@ -282,4 +282,11 @@
         self.daemon = True
 
     def run(self):
-        self.routine()
+        # We know that ShutdwonThreads by nature may not
+        # terminate, and the app may exit underneath them.
+        # Try to squash exceptions here in the case of a 
+        # timeout.
+        try:
+            self.routine()
+        except:
+            pass

Modified: trunk/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- trunk/sage/python/sage/wallaby/wallabyoperations.py	2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/sage/python/sage/wallaby/wallabyoperations.py	2012-06-20 14:54:11 UTC (rev 5421)
@@ -247,6 +247,14 @@
                 log.debug("WallabyOperations: %s seconds to refresh %s" % (delta, attr)) 
                 return d
 
+            # Wrap the entire cache thread with an exception handler
+            def wrap_maintain_cache():
+               try:
+                  maintain_cache(self)
+                  log.debug("WallabyOperations: cache maintenance thread exited")
+               except:
+                  pass
+
             if self._maintain_cache is not None and \
                self._maintain_cache.isAlive():
                 # No, you can't start another one.
@@ -256,7 +264,7 @@
 
             if self.broker_uri is not None:
 #              self._maintain_cache = CallThread(cProfile.runctx('maintain_cache(self)', globals(), locals(), filename='sage.stats'), None)
-               self._maintain_cache = CallThread(maintain_cache, None, self)
+               self._maintain_cache = CallThread(wrap_maintain_cache, None)
                self._maintain_cache.daemon = True
                self._maintain_cache.start()
                log.debug("WallabyOperations: start cache maintenance thread")
@@ -287,6 +295,7 @@
                 self._condition.notify()
                 self._condition.release()
                 if wait and self._maintain_cache.isAlive():
+                    log.debug("WallabyOperations: waiting for cache maintenance thread to exit")
                     self._maintain_cache.join(timeout)
                 log.debug("WallabyOperations: stopped cache maintenance thread")
 



More information about the cumin-developers mailing list