responses to sdiehl code review

This commit is contained in:
fawce
2012-07-18 17:20:31 -04:00
parent 6415f59398
commit fb2b0c3be5
4 changed files with 10 additions and 19 deletions
+2 -1
View File
@@ -90,7 +90,8 @@ class TradeSimulationClient(Component):
)
self.logger = Logger("Print")
# THIS IS A CLASS!
# N.B. that this is a class, which is instantiated later
# in run_algorithm. The class provides a generator.
self.stdout_capture = stdout_only_pipe
def do_work(self):
+2 -8
View File
@@ -269,9 +269,6 @@ class Component(object):
# ----------------
# Control Dispatch
# Only run a single iteration here, just before exit.
# This helps ensure that the Monitor
# Running on every iteration ruins performance.
# ----------------
assert self.control_in, 'Component does not have a control_in socket'
@@ -327,11 +324,8 @@ class Component(object):
elif event == CONTROL_PROTOCOL.KILL:
self.kill()
# =========
# Hard Kill
# =========
# Just exit.
# In case we didn't receive a ping, send a pre-emptive
# pong to the monitor.
elif self.last_ping and time.time() - self.last_ping > 1:
# send a ping ahead of schedule
pre_pong = time.time()
+4 -6
View File
@@ -295,12 +295,6 @@ class Controller(object):
socks = dict(poller.poll(0))
tic = time.time()
# We break out of this loop if the time between
# sending and receiving the heartbeat is more
# than our poll period.
# if tic - self.ctime > self.period:
# break
if socks.get(self.router) == self.zmq.POLLIN:
rawmessage = self.router.recv()
@@ -315,6 +309,10 @@ class Controller(object):
log.error('Invalid frame', rawmessage)
pass
# We break out of this loop if the time between
# sending and receiving the heartbeat is more
# than our poll period.
if tic - self.ctime > self.period:
log.info("heartbeat loop timedout: %s" % (tic - self.ctime))
log.info(repr(self.responses))
+2 -4
View File
@@ -646,14 +646,12 @@ def LOG_FRAME(payload):
def LOG_UNFRAME(msg):
"""
Expects a json serialized dictionary in event/payload format.
msg should be a tuple of ('LOG',dict)
"""
record = msgpack.loads(msg)
assert isinstance(record, tuple)
assert len(record) == 2
assert record[0] == 'LOG'
payload = record[1]
assert payload['e'] == 'log'
assert payload.has_key('p')
return payload['p']
return payload