Cleaner exception/shutdown procedures.

This commit is contained in:
Stephen Diehl
2012-04-26 14:42:38 -04:00
parent e0d3811aed
commit 08f7b115ac
3 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -10,6 +10,7 @@ import uuid
import time
import socket
import gevent
import traceback
import humanhash
# pyzmq
@@ -305,11 +306,11 @@ class Component(object):
self._exception = exc
exc_type, exc_value, exc_traceback = sys.exc_info()
self.stack_trace = exc_traceback
trace = '\n>>>'.join(traceback.format_exception(exc_type, exc_value, exc_traceback))
exception_frame = CONTROL_FRAME(
CONTROL_PROTOCOL.EXCEPTION,
str(exc)
trace
)
self.control_out.send(exception_frame)
+2 -2
View File
@@ -227,7 +227,7 @@ class Feed(Component):
# -- Soft Kill --
elif event == CONTROL_PROTOCOL.SHUTDOWN:
self.done()
self.signal_done()
self.shutdown()
# -- Hard Kill --
@@ -496,7 +496,7 @@ class BaseTransform(Component):
# -- Soft Kill --
elif event == CONTROL_PROTOCOL.SHUTDOWN:
self.done()
self.signal_done()
self.shutdown()
# -- Hard Kill --
+2 -2
View File
@@ -425,8 +425,8 @@ class Controller(object):
"""
Shutdown the system on failure.
"""
self.state = CONTROL_STATES.TERMINATE
self.logging.error('[Controller] System in exception state, shutting down')
self.shutdown(soft=True)
def exception(self, component, failure):
universal = self.exception_universal
@@ -515,7 +515,7 @@ class Controller(object):
return s
def do_error_replay(self):
for (component, time), error in self.error_replay:
for (component, time), error in self.error_replay.iteritems():
self.logging.info('[Controller] Error Log for -- %s --:\n%s' %
(component, error))