From b9e0be6bf05c5033a8c05fd4f1e3ff599a3f9377 Mon Sep 17 00:00:00 2001 From: Stephen Diehl Date: Thu, 5 Jul 2012 17:29:16 -0400 Subject: [PATCH] Blessed commit. --- tests/test_transforms.py | 6 ++++++ zipline/core/host.py | 13 ++----------- zipline/core/monitor.py | 15 ++++++++------- zipline/lines.py | 3 ++- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/test_transforms.py b/tests/test_transforms.py index f4d2f34f..1fec3e7a 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -44,8 +44,14 @@ class ZiplineWithTransformsTestCase(TestCase): self.assertFalse(zipline.sim.exception) class FinanceTransformsTestCase(TestCase): + def setUp(self): self.trading_environment = factory.create_trading_environment() + self.log_handler = LoggingHandler() + self.log_handler.push_application() + + def tearDown(self): + self.log_handler.pop_application() def test_vwap(self): diff --git a/zipline/core/host.py b/zipline/core/host.py index bc52ef85..fe97904f 100644 --- a/zipline/core/host.py +++ b/zipline/core/host.py @@ -16,9 +16,6 @@ class ComponentHost(object): """ def __init__(self, addresses): - self.init(addresses) - - def init(self, addresses): self.addresses = addresses self.running = False @@ -48,14 +45,8 @@ class ComponentHost(object): """ log.info('===== PARENT PID: %s' % os.getppid()) - if catch_exceptions: - try: - self._run() - except Exception as exc: - exc_info = sys.exc_info() - # Reraise the exception - raise exc_info[0], exc_info[1], exc_info[2] - #self.shutdown() + self.open() + #self.shutdown() def shutdown(self, ensure_clean=True): raise NotImplementedError diff --git a/zipline/core/monitor.py b/zipline/core/monitor.py index fb9c7249..be402b46 100644 --- a/zipline/core/monitor.py +++ b/zipline/core/monitor.py @@ -164,7 +164,8 @@ class Controller(object): # ----------------------- # The last breathe of the interpreter will assume that we've # failed unless we specify otherwise. - sys.exitfunc = self.signal_interrupt + if not self.devel: + sys.exitfunc = self.signal_interrupt # We overload this if ( and only if ) the topology exits # cleanly. This prevents failure modes where the monitor # dies. @@ -332,7 +333,7 @@ class Controller(object): if self.devel: log.warn("Shutting down Controller because in devel mode") - sys.exitfunc = lambda: None + #sys.exitfunc = lambda: None self.shutdown(soft=True) log.info('Heartbeat (%s, %s)' % (done, complete)) @@ -351,10 +352,10 @@ class Controller(object): self.shutdown(soft=True) # Noop exit func - sys.exitfunc = lambda: None + #sys.exitfunc = lambda: None # Send SIGHUP to buritto - #self.signal_hangup() + self.signal_hangup() if not self.alive: break @@ -640,7 +641,7 @@ class Controller(object): log.info('Soft Shutdown') self.send_softkill() - self.do_error_replay() + #self.do_error_replay() - self.pub.close() - self.router.close() + #self.pub.close() + #self.router.close() diff --git a/zipline/lines.py b/zipline/lines.py index 54c7ab23..433043e9 100644 --- a/zipline/lines.py +++ b/zipline/lines.py @@ -396,9 +396,10 @@ class SimulatedTrading(object): if self.sim.zmq_flavor == 'thread': log.debug('Blocking') for thread in self.sim.subthreads: + #log.debug('Waiting on %r' % thread) log.debug('Waiting on %r' % thread) - #print 'Waiting on %r' % thread thread.join() + log.debug('Yielded on %r' % thread) else: for process in self.sim.subprocesses: process.join()