From 5c62cce627499ccd2fb0752ee105ada9afb57865 Mon Sep 17 00:00:00 2001 From: fawce Date: Mon, 30 Jul 2012 19:58:09 -0400 Subject: [PATCH] changed logic to take a boolean flag for sighup signaling. --- zipline/core/monitor.py | 14 +++++++------- zipline/lines.py | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/zipline/core/monitor.py b/zipline/core/monitor.py index d3a831f1..1f64cdd9 100644 --- a/zipline/core/monitor.py +++ b/zipline/core/monitor.py @@ -5,6 +5,7 @@ import sys import time import itertools import logbook +import psutil from setproctitle import setproctitle from signal import SIGHUP, SIGINT, SIGKILL, signal @@ -69,7 +70,7 @@ class Controller(object): debug = True period = PARAMETERS.GENERATIONAL_PERIOD - def __init__(self, pub_socket, route_socket): + def __init__(self, pub_socket, route_socket, send_sighup=False): self.nosignals = False self.context = None @@ -97,10 +98,9 @@ class Controller(object): self.missed_beats = Counter() - # if we are inside a test, we want to skip signalling - # back to the parent process. - self.inside_test = 'nose' in inspect.stack()[-1][1] - + self.send_sighup = send_sighup + if self.send_sighup: + log.info("Request to send sighup") def init_zmq(self): @@ -357,8 +357,8 @@ class Controller(object): we're good. The topology exited cleanly and we can prove it. """ - if self.inside_test: - log.warning("Skipping SIGHUP because we're in a nosetest") + if not self.send_sighup: + log.warning("Skipping SIGHUP") return ppid = os.getppid() log.warning("Sending SIGHUP") diff --git a/zipline/lines.py b/zipline/lines.py index c20c1e46..2dc43e2f 100644 --- a/zipline/lines.py +++ b/zipline/lines.py @@ -114,6 +114,7 @@ class SimulatedTrading(object): self.allocator = config['allocator'] self.trading_environment = config['trading_environment'] self.sim_style = config.get('simulation_style') + self.send_sighup = config.get('send_sighup', False) self.leased_sockets = [] @@ -133,6 +134,7 @@ class SimulatedTrading(object): self.con = Controller( sockets[5], sockets[6], + self.send_sighup ) self.started = False