MCPcopy Create free account
hub / github.com/apache/thrift / main

Function main

tutorial/py.twisted/PythonClient.py:39–68  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

37
38@inlineCallbacks
39def main(client):
40 yield client.ping()
41 print('ping()')
42
43 sum = yield client.add(1, 1)
44 print(('1+1=%d' % (sum)))
45
46 work = Work()
47
48 work.op = Operation.DIVIDE
49 work.num1 = 1
50 work.num2 = 0
51
52 try:
53 quotient = yield client.calculate(1, work)
54 print('Whoa? You know how to divide by zero?')
55 print('FYI the answer is %d' % quotient)
56 except InvalidOperation as e:
57 print(('InvalidOperation: %r' % e))
58
59 work.op = Operation.SUBTRACT
60 work.num1 = 15
61 work.num2 = 10
62
63 diff = yield client.calculate(1, work)
64 print(('15-10=%d' % (diff)))
65
66 log = yield client.getStruct(1)
67 print(('Check log: %s' % (log.value)))
68 reactor.stop()
69
70
71if __name__ == '__main__':

Callers

nothing calls this directly

Calls 5

pingMethod · 0.45
addMethod · 0.45
calculateMethod · 0.45
getStructMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected