def yield_connections ( sock ) : while True : log . debug ( 'waiting for connection on %s' , sock . getsockname ( ) ) try : conn , _ = sock . accept ( ) except KeyboardInterrupt : return conn . settimeout ( None ) log . debug ( 'accepted connection on %s' , sock . getsockname ( ) ) yield conn
serversocket in python inbackround, forever
Run a server on the specified socket .
def yield_connections(sock):
    """Run a server on the specified socket."""
    while True:
        log.debug('waiting for connection on %s', sock.getsockname())
        try:
            conn, _ = sock.accept()
        except KeyboardInterrupt:
            return
        conn.settimeout(None)
        log.debug('accepted connection on %s', sock.getsockname())
        yield conn