<s> from pyon . net . endpoint import Publisher , PublisherEndpointUnit <EOL> from pyon . net . messaging import make_node <EOL> import gevent <EOL> import time <EOL> class SpeedPublisherEndpoint ( PublisherEndpointUnit ) : <EOL> def _build_msg ( self , raw_msg ) : <EOL> return raw_msg <EOL> class SpeedPublisher ( Publisher ) : <EOL> endpoint_type = SpeedPublisherEndpoint <EOL> node , iowat = make_node ( ) <EOL> pub = Publisher ( node = node , name = "<STR_LIT>" ) <EOL> counter = <NUM_LIT:0> <EOL> st = time . time ( ) <EOL> def tick ( ) : <EOL> global counter , st <EOL> while True : <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> ct = time . time ( ) <EOL> elapsed_s = ct - st <EOL> mps = counter / elapsed_s <EOL> print counter , "<STR_LIT>" , mps <EOL> def work ( ) : <EOL> global counter <EOL> while True : <EOL> pub . publish ( str ( counter ) ) <EOL> counter += <NUM_LIT:1> <EOL> _gt = gevent . spawn ( tick ) <EOL> _gw = gevent . spawn ( work ) <EOL> gevent . joinall ( [ _gt , _gw ] ) </s>
