def Listen(addr=('0.0.0.0', 0), proto="tcp", *args):
    """A Listener is a generic network listener for stream-oriented protocols.
    Multiple tasks  may invoke methods on a Listener simultaneously.

    Example::

            def handle_connection(conn):
                while True:
                    data = conn.read()
                    if not data:
                        break
                    conn.write(data)

            l = Listen(('127.0.0.1', 8000))

            try:
                while True:
                    try:
                        conn, err = l.accept()
                        t = tasklet(handle_connection)(conn)
                    except KeyboardInterrupt:
                        break
            finally:
                l.close()

            run()
    """

    try:
        listen_class = LISTEN_HANDLERS[proto]
    except __HOLE__:
        raise ValueError("type should be tcp, udp or unix")

    return listen_class(addr, *args)
dataset/ETHPy150Open benoitc/flower/flower/net/__init__.py/Listen