

def handle_events(self, events, env):
    self.env = env
    self.stream_id = env['stream_id']
    self.warnings = []
    new_events = []
    block = []
    for event in events:
        if self._is_exists(event):
            new_events.extend(self._process_block(block, event))
            block = []
        else:
            block.append(event)
    if block:
        new_event = {
            'event_type': 'compute.instance.exists.failed',
            'message_id': str(uuid.uuid4()),
            'timestamp': block[0].get('timestamp', datetime.datetime.utcnow()),
            'stream_id': int(self.stream_id),
            'instance_id': block[0].get('instance_id'),
            'error': 'Notifications, but no .exists notification found.',
            'error_code': 'U0',
        }
        new_events.append(new_event)
    return (events + new_events)

dataset/ETHPy150Open openstack/stacktach-winchester/winchester/pipeline_handler.py UsageHandler.handle_events/original