skytools.scripting: more safety in run_func_safely()
authormartinko <gamato@users.sf.net>
Wed, 24 Apr 2013 12:13:58 +0000 (15:13 +0300)
committermartinko <gamato@users.sf.net>
Wed, 24 Apr 2013 12:13:58 +0000 (15:13 +0300)
Scenario resolved:
startup() fails and some variables are never initialised.  those are used in overridden send_stats() which is called from generic exception handler in run_func_safely().  thus a new exception is raised that would obscure the original exception raised in startup().

python/skytools/scripting.py

index a5e82663188886363c0e194ad813f812b9b2dc43..840f3cf4b6ca3f57eb917c6ccb1c6b873793532b 100644 (file)
@@ -588,7 +588,10 @@ class BaseScript(object):
             self.reset()
             sys.exit(1)
         except Exception, d:
-            self.send_stats()
+            try: # this may fail too
+                self.send_stats()
+            except:
+                pass
             emsg = str(d).rstrip()
             self.reset()
             self.exception_hook(d, emsg)