fix ticket #1382716 (problem was actually more subtle than I originally thought) stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Tue, 04 Jan 2011 15:03:48 +0100
branchstable
changeset 6765 b922e3a817e9
parent 6764 b2c1b481f310
child 6766 1b091b3a0d1e
fix ticket #1382716 (problem was actually more subtle than I originally thought) * log errors happening in looping tasks and repo threads * do not swallow RegistryNotFound exceptions which occur during hook execution (only those happening during hook registry selection)
server/hook.py
server/utils.py
--- a/server/hook.py	Tue Jan 04 14:41:10 2011 +0100
+++ b/server/hook.py	Tue Jan 04 15:03:48 2011 +0100
@@ -307,9 +307,10 @@
 
     def call_hooks(self, event, session=None, **kwargs):
         try:
-            self.vreg['%s_hooks' % event].call_hooks(event, session, **kwargs)
+            registry = self.vreg['%s_hooks' % event]
         except RegistryNotFound:
-            pass # no hooks for this event
+            return # no hooks for this event
+        registry.call_hooks(event, session, **kwargs)
 
 
 for event in ALL_HOOKS:
--- a/server/utils.py	Tue Jan 04 14:41:10 2011 +0100
+++ b/server/utils.py	Tue Jan 04 15:03:48 2011 +0100
@@ -20,6 +20,7 @@
 
 import sys
 import string
+import logging
 from threading import Timer, Thread
 from getpass import getpass
 from random import choice
@@ -129,6 +130,10 @@
         def auto_restart_func(self=self, func=func, args=args):
             try:
                 func(*args)
+            except:
+                logger = logging.getLogger('cubicweb.repository')
+                logger.exception('Unhandled exception in LoopTask %s', self.name)
+                raise
             finally:
                 self.start()
         self.func = auto_restart_func
@@ -158,6 +163,10 @@
         def auto_remove_func(self=self, func=target):
             try:
                 func()
+            except:
+                logger = logging.getLogger('cubicweb.repository')
+                logger.exception('Unhandled exception in RepoThread %s', self._name)
+                raise
             finally:
                 self.running_threads.remove(self)
         Thread.__init__(self, target=auto_remove_func)