changed logic to take a boolean flag for sighup signaling.

This commit is contained in:
fawce
2012-07-30 19:58:09 -04:00
parent 3e577c56c5
commit 5c62cce627
2 changed files with 9 additions and 7 deletions
+7 -7
View File
@@ -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")
+2
View File
@@ -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