'Emit events - possibly delayed.'

def _event_emit_delayed(self, event):

    def event_cleanup(gt, *args, **kwargs):
        'Callback    function    for    greenthread.    Called\n                                                to    cleanup    the    _events_delayed    dictionary    when    an    event\n                                                was    called.\n                                                '
        event = args[0]
        self._events_delayed.pop(event.uuid, None)
    if (event.uuid in self._events_delayed.keys()):
        self._events_delayed[event.uuid].cancel()
        self._events_delayed.pop(event.uuid, None)
        LOG.debug('Removed    pending    event    for    %s    due    to    lifecycle    event', event.uuid)
    if (event.transition == virtevent.EVENT_LIFECYCLE_STOPPED):
        id_ = greenthread.spawn_after(self._lifecycle_delay, self._event_emit, event)
        self._events_delayed[event.uuid] = id_
        id_.link(event_cleanup, event)
    else:
        self._event_emit(event)
