<s> import sys <EOL> import random <EOL> import gevent <EOL> import gevent . socket <EOL> from message import Message , MessageGenerator <EOL> def testClient ( num ) : <EOL> s = gevent . socket . create_connection ( ( "<STR_LIT:localhost>" , <NUM_LIT> ) ) <EOL> m = Message ( ) <EOL> mg = MessageGenerator ( ) <EOL> m . msgtype = <NUM_LIT:0> <EOL> s . send ( m . rawData ( ) ) <EOL> q = s . recv ( <NUM_LIT:100> ) <EOL> mg . addData ( q ) <EOL> g = mg . generate ( ) <EOL> msg2 = g . next ( ) <EOL> print msg2 . msgtype <EOL> print msg2 . value <EOL> m . msgtype = <NUM_LIT:1> <EOL> s . send ( m . rawData ( ) ) <EOL> q = s . recv ( <NUM_LIT:100> ) <EOL> mg . addData ( q ) <EOL> msg2 = g . next ( ) <EOL> print msg2 . msgtype <EOL> print msg2 . value <EOL> m . msgtype = <NUM_LIT:100> <EOL> s . send ( m . rawData ( ) ) <EOL> q = s . recv ( <NUM_LIT:100> ) <EOL> mg . addData ( q ) <EOL> msg2 = g . next ( ) <EOL> print msg2 . msgtype <EOL> print msg2 . value <EOL> m . msgtype = <NUM_LIT> <EOL> m . value = [ <NUM_LIT:0> ] <EOL> s . send ( m . rawData ( ) ) <EOL> iterations = random . randrange ( <NUM_LIT:1000> , <NUM_LIT> ) <EOL> for i in range ( <NUM_LIT:0> , iterations ) : <EOL> q = s . recv ( <NUM_LIT:100> ) <EOL> mg . addData ( q ) <EOL> msg2 = g . next ( ) <EOL> if i % <NUM_LIT:100> == <NUM_LIT:0> : <EOL> print "<STR_LIT>" % ( num , i ) <EOL> s . close ( ) <EOL> def main ( ) : <EOL> z = [ ] <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:1000> ) : <EOL> z . append ( gevent . spawn ( testClient , i ) ) <EOL> gevent . joinall ( z ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( ) ) </s>
