def Process(self, timeout=0):
        """ Check incoming stream for data waiting. If "timeout" is positive - block for as max. this time.
            Returns:
            1) length of processed data if some data were processed;
            2) '0' string if no data were processed but link is alive;
            3) 0 (zero) if underlying connection is closed.
            Take note that in case of disconnection detect during Process() call
            disconnect handlers are called automatically.
        """
        for handler in self._cycleHandlers: handler(self)
        if len(self._pendingExceptions) > 0:
            _pendingException = self._pendingExceptions.pop()
            raise _pendingException[0], _pendingException[1], _pendingException[2]
        if self._owner.Connection.pending_data(timeout):
            try: data=self._owner.Connection.receive()
            except IOError: return
            self.Stream.Parse(data)
            if len(self._pendingExceptions) > 0:
                _pendingException = self._pendingExceptions.pop()
                raise _pendingException[0], _pendingException[1], _pendingException[2]
            if data: return len(data)
        return '0'      # It means that nothing is received but link is alive.
dataset/ETHPy150Open CouchPotato/CouchPotatoServer/libs/xmpp/dispatcher.py/Dispatcher.Process/original