File size: 1,100 Bytes
b657fcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""gRPC server skeleton for AlphaGeometry using proto/alphageometry.proto.



This is a lightweight skeleton; to run it install grpcio and grpcio-tools and

generate Python stubs from the proto. The server handlers delegate to the

existing Pipeline and UniverseManager implementations.

"""
import os
try:
    import grpc
    # import generated modules when available
    from proto import alphageometry_pb2_grpc as pb2_grpc
    from proto import alphageometry_pb2 as pb2
except Exception:
    grpc = None


class AlphaGeometryServicer:
    # placeholder methods if proto generated modules available
    pass


def serve(port: int = 50051):
    if grpc is None:
        raise RuntimeError("grpc not installed or generated stubs are missing")
    server = grpc.server(
        grpc.thread_pool_executor(max_workers=10)
    )
    pb2_grpc.add_AlphaGeometryServicer_to_server(AlphaGeometryServicer(), server)
    server.add_insecure_port(f"[::]:{port}")
    server.start()
    try:
        server.wait_for_termination()
    except KeyboardInterrupt:
        server.stop(0)