'Wait for & dispatch events from native thread
Blocks until native thread indicates some events
are ready. Then dispatches all queued events.'

def _dispatch_events(self):

    try:
        _c = self._event_notify_recv.read(1)
        assert _c
    except ValueError:
        return
    last_close_event = None
    while (not self._event_queue.empty()):
        try:
            event = self._event_queue.get(block=False)
            if isinstance(event, virtevent.LifecycleEvent):
                self._event_emit_delayed(event)
            elif (('conn' in event) and ('reason' in event)):
                last_close_event = event
        except native_Queue.Empty:
            pass
    if (last_close_event is None):
        return
    conn = last_close_event['conn']
    with self._wrapped_conn_lock:
        if (conn == self._wrapped_conn):
            reason = str(last_close_event['reason'])
            msg = (_('Connection    to    libvirt    lost:    %s') % reason)
            self._wrapped_conn = None
            self._queue_conn_event_handler(False, msg)
