def server(host, port, func):
    def handler(conn):
        try:
            yield func(conn)
        finally:
            conn.close()

    listener = Listener(host, port)
    try:
        while True:
            conn = yield listener.accept()
            yield spawn(handler(conn))
    except KeyboardInterrupt:
        pass
    finally:
        listener.close()
A coroutine that runs a network server. Host and port specify the
dataset/ETHPy150Open beetbox/beets/beets/util/bluelet.py/server