<s> """<STR_LIT>""" <EOL> import time <EOL> import logging <EOL> import sys <EOL> from multiprocessing import Process <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT>" ) <EOL> import snakemq <EOL> import snakemq . link <EOL> import snakemq . packeter <EOL> import snakemq . throttle <EOL> DATA_SIZE = <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> <EOL> PORT = <NUM_LIT> <EOL> def srv ( ) : <EOL> s = snakemq . link . Link ( ) <EOL> container = { "<STR_LIT>" : None } <EOL> def on_connect ( conn_id ) : <EOL> container [ "<STR_LIT>" ] = time . time ( ) <EOL> def on_packet_recv ( conn_id , packet ) : <EOL> assert len ( packet ) == DATA_SIZE <EOL> diff = time . time ( ) - container [ "<STR_LIT>" ] <EOL> print "<STR_LIT>" % ( DATA_SIZE / diff / <NUM_LIT> ** <NUM_LIT:2> ) <EOL> def on_disconnect ( conn_id ) : <EOL> s . stop ( ) <EOL> s . add_listener ( ( "<STR_LIT>" , PORT ) ) <EOL> tr = snakemq . packeter . Packeter ( s ) <EOL> tr . on_connect = on_connect <EOL> tr . on_packet_recv = on_packet_recv <EOL> tr . on_disconnect = on_disconnect <EOL> s . loop ( ) <EOL> s . cleanup ( ) <EOL> def cli ( ) : <EOL> s = snakemq . link . Link ( ) <EOL> def on_connect ( conn_id ) : <EOL> tr . send_packet ( conn_id , "<STR_LIT:x>" * DATA_SIZE ) <EOL> def on_packet_sent ( conn_id , packet_id ) : <EOL> s . stop ( ) <EOL> s . add_connector ( ( "<STR_LIT:localhost>" , PORT ) ) <EOL> throttle = snakemq . throttle . Throttle ( s , <NUM_LIT> ) <EOL> tr = snakemq . packeter . Packeter ( throttle ) <EOL> tr . on_connect = on_connect <EOL> tr . on_packet_sent = on_packet_sent <EOL> s . loop ( ) <EOL> s . cleanup ( ) <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> logger . setLevel ( logging . ERROR ) <EOL> thr_srv = Process ( target = srv ) <EOL> thr_srv . start ( ) <EOL> thr_cli = Process ( target = cli ) <EOL> thr_cli . start ( ) <EOL> thr_srv . join ( ) <EOL> thr_cli . join ( ) </s>
