'Start processing the XML streams.
Processing will continue after any recoverable errors
if reconnections are allowed.'

def _process(self):

    while True:
        shutdown = False
        try:
            while (not self.stop.is_set()):
                if (not self.state.ensure(u'connected', wait=0.1)):
                    break
                if (not self.session_started_event.is_set()):
                    self.send_raw(self.stream_header, now=True)
                if (not self.__read_xml()):
                    break
        except KeyboardInterrupt:
            log.debug(u'Keyboard    Escape    Detected    in    _process')
            self.event(u'killed', direct=True)
            shutdown = True
        except SystemExit:
            log.debug(u'SystemExit    in    _process')
            shutdown = True
        except (SyntaxError, ExpatError) as e:
            log.error(u'Error    reading    from    XML    stream.')
            self.exception(e)
        except (Socket.error, ssl.SSLError) as serr:
            self.event(u'socket_error', serr, direct=True)
            log.error(u'Socket    Error    #%s:    %s', serr.errno, serr.strerror)
        except ValueError as e:
            msg = (e.message if hasattr(e, u'message') else e.args[0])
            if (u'I/O    operation    on    closed    file' in msg):
                log.error(u'Can    not    read    from    closed    socket.')
            else:
                self.exception(e)
        except Exception as e:
            if (not self.stop.is_set()):
                log.error(u'Connection    error.')
            self.exception(e)
        if ((not shutdown) and (not self.stop.is_set()) and self.auto_reconnect):
            self.reconnect()
        else:
            self.disconnect()
            break
