def call_process(self, event_id, params): self.processed += 1 p = dict(self.params) if params is not None: p.update(params) with Processor.enter_context() as c, \ Event(event_id=event_id, client=self.client) as event: try: with Processor.started_stopwatch( 'process_method') as stopwatch: stopwatch.start() result = self.processor.process(event, p) return result, c.times, event.created_indices except Exception as e: self.failure_count += 1 logger.error( 'Processor "%s" failed while processing event with id: %s', self.component_id, event_id) logger.error(e) raise e
def test_preserves_times(): with Processor.enter_context() as context: context.add_time("foo", timedelta(seconds=2)) context.add_time("foo", timedelta(seconds=2)) assert context.times["foo"] == timedelta(seconds=4)