def fill_process_list(self): """! @brief Iteration of the main loop. Fills the processing list with events from the event queue. @returns True if some events were moved into the other queue, False otherwise. """ added = False while not self.event_queue_empty(): if self.process_list_full(): return added for event in self.event_queue: # Discard message if below timestamp threshold if event.timestamp() < self.message_timestamp_threshold: self.logger.warning('Skip processing event because resource is older than threshold: %s vs %s', event.timestamp(), self.message_timestamp_threshold) self.remove_event_from_queues(event) self.statsd.incr('productstatus_rejected_events') else: self.move_to_process_list(event) added = True break return added
def sort_timestamp(event): return event.timestamp()
def test_productstatus_event_factory_unrecognized(self): event = eva.event.ProductstatusBaseEvent.factory(unrecognized_serialized_event) self.assertIsInstance(event, eva.event.ProductstatusBaseEvent) self.assertEqual(event.id(), '20000000-0000-0000-0000-000000000002') self.assertEqual(event.timestamp(), eva.coerce_to_utc(datetime.datetime(2016, 1, 5, 12, 0, 0))) self.assertEqual(event.protocol_version(), [1, 5, 0])