pyngus/sockets.py
def read_socket_input(connection, socket_obj):
    """Read from the network layer and processes all data read.  Can
    support both blocking and non-blocking sockets.
    Returns the number of input bytes processed, or EOS if input processing
    is done.  Any exceptions raised by the socket are re-raised.
    """
    count = connection.needs_input
    if count <= 0:
        return count  # 0 or EOS

    while True:
        try:
            sock_data = socket_obj.recv(count)
            break
        except socket.timeout as e:
            LOG.debug("Socket timeout exception %s", str(e))
            raise  # caller must handle
        except socket.error as e:
            err = e.errno
            if err in [errno.EAGAIN,
                       errno.EWOULDBLOCK,
                       errno.EINTR]:
                # try again later
                return 0
            # otherwise, unrecoverable, caller must handle
            LOG.debug("Socket error exception %s", str(e))
            raise
        except Exception as e:  # beats me... assume fatal
            LOG.debug("unknown socket exception %s", str(e))
            raise  # caller must handle

    if len(sock_data) > 0:
        count = connection.process_input(sock_data)
    else:
        LOG.debug("Socket closed")
        count = Connection.EOS
        connection.close_input()
        connection.close_output()
    return count
def read_socket_input(connection, socket_obj):
    count = connection.needs_input
    if count <= 0:
        return count  # 0 or EOS

    while True:
        try:
            sock_data = socket_obj.recv(count)
            break
        except socket.timeout as e:
            LOG.debug("Socket timeout exception %s", str(e))
            raise  # caller must handle
        except socket.error as e:
            err = e.errno
            if err in [errno.EAGAIN,
                       errno.EWOULDBLOCK,
                       errno.EINTR]:
                # try again later
                return 0
            # otherwise, unrecoverable, caller must handle
            LOG.debug("Socket error exception %s", str(e))
            raise
        except Exception as e:  # beats me... assume fatal
            LOG.debug("unknown socket exception %s", str(e))
            raise  # caller must handle

    if len(sock_data) > 0:
        count = connection.process_input(sock_data)
    else:
        LOG.debug("Socket closed")
        count = Connection.EOS
        connection.close_input()
        connection.close_output()
    return count
def read_socket_input ( connection , socket_obj ) : count = connection . needs_input if count <= 0 : return count # 0 or EOS while True : try : sock_data = socket_obj . recv ( count ) break except socket . timeout as e : LOG . debug ( "Socket timeout exception %s" , str ( e ) ) raise # caller must handle except socket . error as e : err = e . errno if err in [ errno . EAGAIN , errno . EWOULDBLOCK , errno . EINTR ] : # try again later return 0 # otherwise, unrecoverable, caller must handle LOG . debug ( "Socket error exception %s" , str ( e ) ) raise except Exception as e : # beats me... assume fatal LOG . debug ( "unknown socket exception %s" , str ( e ) ) raise # caller must handle if len ( sock_data ) > 0 : count = connection . process_input ( sock_data ) else : LOG . debug ( "Socket closed" ) count = Connection . EOS connection . close_input ( ) connection . close_output ( ) return count
Read from the network layer and processes all data read.  Can
    support both blocking and non-blocking sockets.
    Returns the number of input bytes processed, or EOS if input processing
    is done.  Any exceptions raised by the socket are re-raised.
Read from the network layer and processes all data read . Can support both blocking and non - blocking sockets . Returns the number of input bytes processed or EOS if input processing is done . Any exceptions raised by the socket are re - raised .