<s> import unittest <EOL> import gevent <EOL> from scales . thrift import Thrift <EOL> from integration . thrift . gen_py . example_rpc_service import ( <EOL> ExampleService , <EOL> ttypes <EOL> ) <EOL> class ThriftTestCase ( unittest . TestCase ) : <EOL> BUILDER = Thrift <EOL> def setUp ( self ) : <EOL> self . client = self . BUILDER . NewClient ( ExampleService . Iface , '<STR_LIT>' ) <EOL> def _send_request ( self ) : <EOL> try : <EOL> ret = self . client . passMessage ( ttypes . Message ( '<STR_LIT>' ) ) <EOL> return ret . content == '<STR_LIT>' <EOL> except : <EOL> return False <EOL> def test ( self ) : <EOL> ret = self . _send_request ( ) <EOL> self . assertTrue ( ret ) <EOL> def test_concurrency ( self ) : <EOL> num_threads = <NUM_LIT:3> <EOL> num_iterations = <NUM_LIT:1000> <EOL> def _test ( ) : <EOL> for _ in xrange ( num_iterations ) : <EOL> self . assertTrue ( self . _send_request ( ) ) <EOL> greenlets = [ ] <EOL> for _ in xrange ( num_threads ) : <EOL> greenlets . append ( gevent . spawn ( _test ) ) <EOL> [ g . join ( ) for g in greenlets ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
