pyngus/connection.py
def process(self, now):
        """Perform connection state processing."""
        if self._pn_connection is None:
            LOG.error("Connection.process() called on destroyed connection!")
            return 0

        # do nothing until the connection has been opened
        if self._pn_connection.state & proton.Endpoint.LOCAL_UNINIT:
            return 0

        if self._pn_sasl and not self._sasl_done:
            # wait until SASL has authenticated
            if (_PROTON_VERSION < (0, 10)):
                if self._pn_sasl.state not in (proton.SASL.STATE_PASS,
                                               proton.SASL.STATE_FAIL):
                    LOG.debug("SASL in progress. State=%s",
                              str(self._pn_sasl.state))
                    if self._handler:
                        with self._callback_lock:
                            self._handler.sasl_step(self, self._pn_sasl)
                    return self._next_deadline

                self._sasl_done = True
                if self._handler:
                    with self._callback_lock:
                        self._handler.sasl_done(self, self._pn_sasl,
                                                self._pn_sasl.outcome)
            else:
                if self._pn_sasl.outcome is not None:
                    self._sasl_done = True
                    if self._handler:
                        with self._callback_lock:
                            self._handler.sasl_done(self, self._pn_sasl,
                                                    self._pn_sasl.outcome)

        # process timer events:
        timer_deadline = self._expire_timers(now)
        transport_deadline = self._pn_transport.tick(now)
        if timer_deadline and transport_deadline:
            self._next_deadline = min(timer_deadline, transport_deadline)
        else:
            self._next_deadline = timer_deadline or transport_deadline

        # process events from proton:
        pn_event = self._pn_collector.peek()
        while pn_event:
            # LOG.debug("pn_event: %s received", pn_event.type)
            if _Link._handle_proton_event(pn_event, self):
                pass
            elif self._handle_proton_event(pn_event):
                pass
            elif _SessionProxy._handle_proton_event(pn_event, self):
                pass
            self._pn_collector.pop()
            pn_event = self._pn_collector.peek()

        # check for connection failure after processing all pending
        # engine events:
        if self._error:
            if self._handler:
                # nag application until connection is destroyed
                self._next_deadline = now
                with self._callback_lock:
                    self._handler.connection_failed(self, self._error)
        elif (self._endpoint_state == self._CLOSED and
              self._read_done and self._write_done):
            # invoke closed callback after endpoint has fully closed and
            # all pending I/O has completed:
            if self._handler:
                with self._callback_lock:
                    self._handler.connection_closed(self)

        return self._next_deadline
def process(self, now):
        if self._pn_connection is None:
            LOG.error("Connection.process() called on destroyed connection!")
            return 0

        # do nothing until the connection has been opened
        if self._pn_connection.state & proton.Endpoint.LOCAL_UNINIT:
            return 0

        if self._pn_sasl and not self._sasl_done:
            # wait until SASL has authenticated
            if (_PROTON_VERSION < (0, 10)):
                if self._pn_sasl.state not in (proton.SASL.STATE_PASS,
                                               proton.SASL.STATE_FAIL):
                    LOG.debug("SASL in progress. State=%s",
                              str(self._pn_sasl.state))
                    if self._handler:
                        with self._callback_lock:
                            self._handler.sasl_step(self, self._pn_sasl)
                    return self._next_deadline

                self._sasl_done = True
                if self._handler:
                    with self._callback_lock:
                        self._handler.sasl_done(self, self._pn_sasl,
                                                self._pn_sasl.outcome)
            else:
                if self._pn_sasl.outcome is not None:
                    self._sasl_done = True
                    if self._handler:
                        with self._callback_lock:
                            self._handler.sasl_done(self, self._pn_sasl,
                                                    self._pn_sasl.outcome)

        # process timer events:
        timer_deadline = self._expire_timers(now)
        transport_deadline = self._pn_transport.tick(now)
        if timer_deadline and transport_deadline:
            self._next_deadline = min(timer_deadline, transport_deadline)
        else:
            self._next_deadline = timer_deadline or transport_deadline

        # process events from proton:
        pn_event = self._pn_collector.peek()
        while pn_event:
            # LOG.debug("pn_event: %s received", pn_event.type)
            if _Link._handle_proton_event(pn_event, self):
                pass
            elif self._handle_proton_event(pn_event):
                pass
            elif _SessionProxy._handle_proton_event(pn_event, self):
                pass
            self._pn_collector.pop()
            pn_event = self._pn_collector.peek()

        # check for connection failure after processing all pending
        # engine events:
        if self._error:
            if self._handler:
                # nag application until connection is destroyed
                self._next_deadline = now
                with self._callback_lock:
                    self._handler.connection_failed(self, self._error)
        elif (self._endpoint_state == self._CLOSED and
              self._read_done and self._write_done):
            # invoke closed callback after endpoint has fully closed and
            # all pending I/O has completed:
            if self._handler:
                with self._callback_lock:
                    self._handler.connection_closed(self)

        return self._next_deadline
def process ( self , now ) : if self . _pn_connection is None : LOG . error ( "Connection.process() called on destroyed connection!" ) return 0 # do nothing until the connection has been opened if self . _pn_connection . state & proton . Endpoint . LOCAL_UNINIT : return 0 if self . _pn_sasl and not self . _sasl_done : # wait until SASL has authenticated if ( _PROTON_VERSION < ( 0 , 10 ) ) : if self . _pn_sasl . state not in ( proton . SASL . STATE_PASS , proton . SASL . STATE_FAIL ) : LOG . debug ( "SASL in progress. State=%s" , str ( self . _pn_sasl . state ) ) if self . _handler : with self . _callback_lock : self . _handler . sasl_step ( self , self . _pn_sasl ) return self . _next_deadline self . _sasl_done = True if self . _handler : with self . _callback_lock : self . _handler . sasl_done ( self , self . _pn_sasl , self . _pn_sasl . outcome ) else : if self . _pn_sasl . outcome is not None : self . _sasl_done = True if self . _handler : with self . _callback_lock : self . _handler . sasl_done ( self , self . _pn_sasl , self . _pn_sasl . outcome ) # process timer events: timer_deadline = self . _expire_timers ( now ) transport_deadline = self . _pn_transport . tick ( now ) if timer_deadline and transport_deadline : self . _next_deadline = min ( timer_deadline , transport_deadline ) else : self . _next_deadline = timer_deadline or transport_deadline # process events from proton: pn_event = self . _pn_collector . peek ( ) while pn_event : # LOG.debug("pn_event: %s received", pn_event.type) if _Link . _handle_proton_event ( pn_event , self ) : pass elif self . _handle_proton_event ( pn_event ) : pass elif _SessionProxy . _handle_proton_event ( pn_event , self ) : pass self . _pn_collector . pop ( ) pn_event = self . _pn_collector . peek ( ) # check for connection failure after processing all pending # engine events: if self . _error : if self . _handler : # nag application until connection is destroyed self . _next_deadline = now with self . _callback_lock : self . _handler . connection_failed ( self , self . _error ) elif ( self . _endpoint_state == self . _CLOSED and self . _read_done and self . _write_done ) : # invoke closed callback after endpoint has fully closed and # all pending I/O has completed: if self . _handler : with self . _callback_lock : self . _handler . connection_closed ( self ) return self . _next_deadline
Perform connection state processing.
Perform connection state processing .