Checks to make sure that an Event has a type before checking type.

The Dividend event is currently missing 'type', causing the type
check to fail.

TODO: Add a type to Dividends.
This commit is contained in:
Eddie Hebert
2013-02-07 18:17:26 -05:00
parent 26ff73072c
commit 79f7fe69ef
+4 -3
View File
@@ -136,7 +136,8 @@ class StatefulTransform(object):
log.info('Running StatefulTransform [%s]' % self.get_hash())
for message in stream_in:
# we only handle TRADE events.
if message.type != DATASOURCE_TYPE.TRADE:
if (hasattr(message, 'type')
and message.type != DATASOURCE_TYPE.TRADE):
continue
# allow upstream generators to yield None to avoid
# blocking.
@@ -217,8 +218,8 @@ class EventWindow(object):
def update(self, event):
if event.type != DATASOURCE_TYPE.TRADE:
continue
if hasattr(event, 'type') and event.type != DATASOURCE_TYPE.TRADE:
return
self.assert_well_formed(event)
# Add new event and increment totals.