def _dispatch_events(self):
    'Wait for & dispatch events from native thread\n\n        Blocks until native thread indicates some events\n        are ready. Then dispatches all queued events.\n        '
    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.emit_event(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 = last_close_event['reason']
            _error = (_('Connection to libvirt lost: %s') % reason)
            LOG.warn(_error)
            self._wrapped_conn = None
            self._set_host_enabled(False, disable_reason=_error)
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):
    'Wait for & dispatch events from native thread\n\n        Blocks until native thread indicates some events\n        are ready. Then dispatches all queued events.\n        '
    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.emit_event(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 = last_close_event['reason']
            _error = (_('Connection to libvirt lost: %s') % reason)
            LOG.warn(_error)
            self._wrapped_conn = None
            self._set_host_enabled(False, disable_reason=_error)