def srv():
    s = snakemq.link.Link()
    container = {"start_time": None}

    def on_connect(conn_id):
        container["start_time"] = time.time()

    def on_packet_recv(conn_id, packet):
        assert len(packet) == DATA_SIZE
        diff = time.time() - container["start_time"]
        print "flow: %.02f MBps" % (DATA_SIZE / diff / 1024**2)

    def on_disconnect(conn_id):
        s.stop()

    s.add_listener(("", PORT))
    tr = snakemq.packeter.Packeter(s)
    tr.on_connect = on_connect
    tr.on_packet_recv = on_packet_recv
    tr.on_disconnect = on_disconnect
    s.loop()
    s.cleanup()

###########################################################################
dataset/ETHPy150Open dsiroky/snakemq/tests/performance/packeter_single_large_throttled.py/srv/original