<s> import thriftpy <EOL> from thriftpy . protocol import TCyBinaryProtocolFactory <EOL> from thriftpy . transport import TCyBufferedTransportFactory <EOL> from thriftpy . rpc import make_server <EOL> calc_thrift = thriftpy . load ( "<STR_LIT>" , module_name = "<STR_LIT>" ) <EOL> class Dispatcher ( object ) : <EOL> def add ( self , a , b ) : <EOL> print ( "<STR_LIT>" % ( a , b ) ) <EOL> return a + b <EOL> def sub ( self , a , b ) : <EOL> print ( "<STR_LIT>" % ( a , b ) ) <EOL> return a - b <EOL> def mult ( self , a , b ) : <EOL> print ( "<STR_LIT>" % ( a , b ) ) <EOL> return a * b <EOL> def div ( self , a , b ) : <EOL> print ( "<STR_LIT>" % ( a , b ) ) <EOL> return a // b <EOL> def main ( ) : <EOL> server = make_server ( calc_thrift . Calculator , Dispatcher ( ) , <EOL> '<STR_LIT:127.0.0.1>' , <NUM_LIT> , <EOL> proto_factory = TCyBinaryProtocolFactory ( ) , <EOL> trans_factory = TCyBufferedTransportFactory ( ) ) <EOL> print ( "<STR_LIT>" ) <EOL> server . serve ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
