Ejemplo n.º 1
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    hello_pb2_grpc.add_HelloServicer_to_server(HelloServicer(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    print("Running a grpc hello service on localhost:50051")
    while True:
        sleep(10)
Ejemplo n.º 2
0
def serve():
    print('starting server..')
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    hello_pb2_grpc.add_HelloServicer_to_server(Hello(), server)
    server.add_insecure_port('[::]:50051')
    print('started server on http://localhost:50051')
    server.start()
    server.wait_for_termination()
Ejemplo n.º 3
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    hello_pb2_grpc.add_HelloServicer_to_server(HelloServicer(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    try:
        while True:
            time.sleep(86400)
    except KeyboardInterrupt:
        server.stop(0)
Ejemplo n.º 4
0
def grpc_server(grpc_addr):
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=2))
    hello_pb2_grpc.add_HelloServicer_to_server(rpc.HelloGRpcServer(), server)
    for addr in grpc_addr:
        server.add_insecure_port(addr)

    server.start()

    yield server

    server.stop(0)
Ejemplo n.º 5
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=2))
    server.add_insecure_port('[::]:%d' % (GRPC_PORT))
    add_HelloServicer_to_server(SendBackDatadogHeaders(), server)
    server.start()
    print('Waiting on port %d' % (GRPC_PORT))
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)
Ejemplo n.º 6
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))

    add_HelloServicer_to_server(Hello(), server)

    server.add_insecure_port('[::]:30011')
    server.start()
    try:
        while True:
            time.sleep(60 * 60 * 24)
    except KeyboardInterrupt:
        server.stop(0)
Ejemplo n.º 7
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    hello_pb2_grpc.add_HelloServicer_to_server(Hello(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    server.wait_for_termination()
Ejemplo n.º 8
0
# -*- coding:utf-8; mode:python -*-
# This example is based on https://github.com/grpc/grpc/tree/v1.6.x/examples/python/helloworld

from concurrent import futures
import time

import grpc
import hello_pb2
import hello_pb2_grpc

DAY_SECONDS = 24 * 60 * 60


class Hello(hello_pb2_grpc.HelloServicer):
    def write(self, request, context):
        print("Client sent: '{}'".format(request.message))
        return hello_pb2.PrintReply()


server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
hello_pb2_grpc.add_HelloServicer_to_server(Hello(), server)
server.add_insecure_port('0.0.0.0:2000')
server.start()

try:
    while True:
        time.sleep(DAY_SECONDS)

except KeyboardInterrupt:
    server.stop(0)