MCPcopy Create free account
hub / github.com/actix/examples / op

Function op

protobuf/client.py:21–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19import aiohttp
20
21def op():
22 try:
23 obj = test_pb2.MyObj()
24 obj.number = 9
25 obj.name = 'USB'
26
27 #Serialize
28 sendDataStr = obj.SerializeToString()
29 #print serialized string value
30 print('serialized string:', sendDataStr)
31 #------------------------#
32 # message transmission #
33 #------------------------#
34 receiveDataStr = sendDataStr
35 receiveData = test_pb2.MyObj()
36
37 #Deserialize
38 receiveData.ParseFromString(receiveDataStr)
39 print('pares serialize string, return: devId = ', receiveData.number, ', name = ', receiveData.name)
40 except(Exception, e):
41 print(Exception, ':', e)
42 print(traceback.print_exc())
43 errInfo = sys.exc_info()
44 print(errInfo[0], ':', errInfo[1])
45
46
47async def fetch(session):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected