intersticial commit for scott to pick

This commit is contained in:
fawce
2012-07-25 12:28:21 -04:00
parent c02d15016a
commit 52b597f089
3 changed files with 14 additions and 11 deletions
+8 -5
View File
@@ -17,7 +17,7 @@ EXTENDED_TIMEOUT = 90
allocator = AddressAllocator(1000)
class FinanceTestCase(TestCase):
class ExceptionTestCase(TestCase):
leased_sockets = defaultdict(list)
@@ -26,7 +26,8 @@ class FinanceTestCase(TestCase):
'allocator' : allocator,
'sid' : 133,
'devel' : False,
'results_socket' : allocator.lease(1)[0]
'results_socket' : allocator.lease(1)[0],
'simulation_style' : SIMULATION_STYLE.FIXED_SLIPPAGE
}
self.ctx = zmq.Context()
@@ -41,9 +42,8 @@ class FinanceTestCase(TestCase):
# Simulation
# ----------
self.zipline_test_config['simulation_style'] = \
SIMULATION_STYLE.FIXED_SLIPPAGE
self.zipline_test_config['algorithm'] = ExceptionAlgorithm('initialize')
self.zipline_test_config['algorithm'] = \
ExceptionAlgorithm('initialize')
zipline = SimulatedTrading.create_test_zipline(
**self.zipline_test_config
@@ -58,3 +58,6 @@ class FinanceTestCase(TestCase):
# - exception protocol to use prefix/payload as EXCEPT,
# and the stack trace
# - test exception in handle_data
# - define more zipline failure modes: exception in other
# components, exception in Monitor, etc. write tests
# for those scenarios.
+2 -3
View File
@@ -185,14 +185,13 @@ class TradeSimulationClient(Component):
# LOG_EXTRA_FIELDS in zipline/protocol.py
self.do_op(self.algorithm.handle_data, data)
def exception_callback(self, trace):
def exception_callback(self, exc_type, exc_value, exc_traceback):
if self.results_socket:
self.out_socket.send("EXCEPTION")
def do_op(self, callable_op, *args, **kwargs):
""" Wrap a callable operation with the zmq logbook
handler if it exits. Also wrap the invocation of callable
op in a try/except, and relay """
handler if it exits."""
if self.zmq_out:
def inject_event_data(record):
+4 -3
View File
@@ -511,12 +511,13 @@ class Component(object):
self._exception = exc
exc_type, exc_value, exc_traceback = sys.exc_info()
trace = ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback))
sys.stdout.write(trace)
if hasattr(self, 'exception_callback'):
self.exception_callback(trace)
if hasattr(self, 'exception_callback') and self.exception_callback:
self.exception_callback(exc_type, exc_value, exc_traceback)
if hasattr(self, 'control_out'):
if hasattr(self, 'control_out') and self.control_out:
exception_frame = CONTROL_FRAME(
CONTROL_PROTOCOL.EXCEPTION,
trace