Update logging system

This commit is contained in:
Stephen Diehl
2012-06-12 07:11:52 -04:00
parent 2d85ec4d95
commit 06e6207020
4 changed files with 12 additions and 99 deletions
+1 -1
View File
@@ -357,7 +357,7 @@ class Component(object):
#notify internal work look that we're done
self.done = True # TODO: use state flag
log.info("[%s] DONE" % self.get_id)
#log.info("[%s] DONE" % self.get_id)
# -----------
# Messaging
+2 -2
View File
@@ -100,11 +100,11 @@ class ComponentHost(Component):
self.sockets.append(self.sync_socket)
def open(self):
log.info('== Roll Call ==\n')
log.info('== Roll Call ==')
for component in self.components.itervalues():
log.info(component)
log.info('== End Roll Call ==\n')
log.info('== End Roll Call ==')
for component in self.components.itervalues():
self.launch_component(component)
+6 -96
View File
@@ -7,106 +7,13 @@ import gevent_zeromq
from collections import OrderedDict
from zipline.utils.gpoll import _Poller as GeventPoller
from zipline.protocol import CONTROL_PROTOCOL, CONTROL_FRAME, \
CONTROL_UNFRAME, CONTROL_STATES, INVALID_CONTROL_FRAME \
states = CONTROL_STATES
from zipline.utils.gpoll import _Poller as GeventPoller
# Roll Call ( Discovery )
# -----------------------
#
# Controller ( 'foo', 'bar', 'fizz', 'pop' )
# ------------------
# | | | |
# +---+
# | 0 | ? ? ?
# +---+
# |
# IDENTITY: foo
# get message: PROTOCOL.HEARTBEAT
# reply with PROTOCOL.OK
#
# Controller topology = ( 'foo', 'bar', 'fizz', 'pop' )
# 'foo' in topology = YES ->
# track 'foo'
# ------------------
# | | | |
# +---+
# | 1 | ? ? ?
# +---+
# Heartbeating
# ------------
#
# Controller ( time = 2.717828 )
# ------------------
# | | | |
# +---+ +---+ +---+ +---+
# | 0 | | 0 | | 0 | | 0 |
# +---+ +---+ +---+ +---+
# |
# IDENTITY: foo
# get message: time = 2.717828
# reply with [ foo, 2.71828 ]
#
# Controller ( foo.status = OK )
# ------------------
# | | | |
# +---+ +---+ +---+ +---+
# | 1 | | 0 | | 0 | | 0 |
# +---+ +---+ +---+ +---+
# |
# Controller tracks this node as good
# for this heartbeat
# Shutdown
# --------
#
# Controller ( state = RUNNING )
# ------------------
# | | | |
# +---+ +---+ +---+ +---+
# | 1 | | 1 | | 1 | | 1 |
# +---+ +---+ +---+ +---+
# |
# IDENTITY: foo
# send [ DONE ]
# Controller ( state = SHUTDOWN )
# Controller topology.remove('foo')
# ------------------
# | | |
# +---+ +---+ +---+ +---+
# | | | 1 | | 1 | | 1 |
# +---+ +---+ +---+ +---+
# |
# IDENTITY: foo
# yield, stop sending messages
# Termination
# ------------
#
# Controller ( state = TERMINATE )
# ------------------
# | | | |
# +---+ +---+ +---+ +---+
# | 1 | | 1 | | 1 | | 1 |
# +---+ +---+ +---+ +---+
# |
# get message PROTOCOL.KILL
# Controller ( state = TERMINATE )
# ------------------
# | | | |
# +---+ +---+ +---+ +---+
# | 0 | | 0 | | 0 | | 0 |
# +---+ +---+ +---+ +---+
INIT, SOURCES_READY, RUNNING, TERMINATE = CONTROL_STATES
state_transitions = frozenset([
CONTROLLER_TRANSITIONS = frozenset([
(-1 , INIT),
(INIT , SOURCES_READY),
(SOURCES_READY , RUNNING),
@@ -233,7 +140,7 @@ class Controller(object):
def state(self, new):
old, self._state = self._state, new
if (old, new) not in state_transitions:
if (old, new) not in CONTROLLER_TRANSITIONS:
raise RuntimeError("Invalid State Transition : %s -> %s" %(old, new))
else:
log.error("State Transition : %s -> %s" %(old, new))
@@ -572,6 +479,9 @@ class Controller(object):
def shutdown(self, hard=False, soft=True, context=None):
if self.state is CONTROL_STATES.TERMINATE:
return
if not self.polling:
return
+3
View File
@@ -287,12 +287,15 @@ class PerformanceTracker(object):
if self.results_socket:
msg = zp.PERF_FRAME(self.to_dict())
self.results_socket.send(msg)
else:
log.info(self.to_dict())
#
if self.trading_environment.max_drawdown:
returns = self.todays_performance.returns
max_dd = -1 * self.trading_environment.max_drawdown
if returns < max_dd:
print 0/0
log.info(str(returns) + " broke through " + str(max_dd))
log.info("Exceeded max drawdown.")
# mark the perf period with max loss flag,