-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.py
More file actions
36 lines (24 loc) · 960 Bytes
/
test_server.py
File metadata and controls
36 lines (24 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from concurrent import futures
import grpc
import jsonpickle
from plibs.manager.manager_pb2 import StartSimulationRequest, StartSimulationResponse
from plibs.manager.manager_pb2_grpc import ManagerServicer, add_ManagerServicer_to_server
class ManagerModule(ManagerServicer):
def __init__(self) -> None:
pass
def StartSimulation(self, request: StartSimulationRequest, context) -> StartSimulationResponse:
return StartSimulationResponse(
simulation_uuid=request.simulation_uuid,
result=jsonpickle.encode(
{"id": 1, "name": "David", "age": 33}, unpicklable=False)
)
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
add_ManagerServicer_to_server(ManagerModule(), server)
server.add_insecure_port("[::]:50051")
print("Listening...")
server.start()
server.wait_for_termination()
if __name__ == '__main__':
serve()