'Remove all pending events for an instance.
This will remove all events currently pending for an instance
and return them (indexed by event name).
:param instance: the instance for which events should be purged
:returns: a dictionary of {event_name: eventlet.event.Event}'

def clear_events_for_instance(self, instance):

    @utils.synchronized(self._lock_name(instance))
    def _clear_events():
        if (self._events is None):
            LOG.debug('Unexpected    attempt    to    clear    events    during    shutdown', instance=instance)
            return dict()
        return self._events.pop(instance.uuid, {})
    return _clear_events()
