Hello Lidi Zheng, Thanks for the response. As you said,using "Await.ready" or "Await.block" will block the program and return me the result. In my case, I want it to execute asynchronously. There should be no blocking. Let the server return the response when it has finished computing. Is that possible?
Regards, S Sathish Babu On Wednesday, 30 January 2019 23:37:04 UTC+5:30, Lidi Zheng wrote: > > Hello, > > The Scala client is exiting too quick that the future is not yet > completed. You may use "Await.ready" or "Await.result" to explicitly block > the program. > > Cheers, > Lidi Zheng > > On Tue, Jan 29, 2019 at 10:58 PM S SATHISH BABU <[email protected] > <javascript:>> wrote: > >> Hello, >> I am making a communication between my Scala gRPC client and python >> gRPC server. My issue is when I make a blocking call from scala client, my >> request is handled. But in case of asynchronous stub, the request is not >> delivered at all. Can anyone help me out with this?. >> >> Python gRPC server code >> >> from gRPC2 import message_pb2, message_pb2_grpc >> import grpc >> from concurrent import futures >> import time >> >> >> class HandlerServicer(message_pb2_grpc.HandlerServicer): >> >> def request_handler(self, request, context): >> print('Received request:', request, request.request_message) >> response = 'Reponse' >> time.sleep(10) >> return message_pb2.Response(response_message=response) >> >> >> handler_server = grpc.server(futures.ThreadPoolExecutor()) >> message_pb2_grpc.add_HandlerServicer_to_server(HandlerServicer(), >> handler_server) >> handler_server.add_insecure_port("[::]:{}".format(5000)) >> >> print('Starting server...') >> handler_server.start() >> try: >> while True: >> time.sleep(60*60*60) >> except KeyboardInterrupt: >> print('Stopping server...') >> handler_server.stop(0) >> >> >> Scala gRPC client code: >> >> import io.grpc.ManagedChannelBuilder >> import message._ >> >> import scala.concurrent.Future >> import scala.concurrent.ExecutionContext >> >> object HandlerClient extends App { >> >> val channel = ManagedChannelBuilder.forAddress("localhost", >> 5000).usePlaintext().build() >> val request = Request("Request") >> implicit val ec = ExecutionContext.global >> >> // Making a Async call >> val stub = HandlerGrpc.stub(channel) >> val future = stub.requestHandler(request) >> future onComplete println >> } >> >> >> >> Proto file: >> >> syntax = "proto3"; >> >> service Handler{ >> rpc request_handler(Request) returns (Response){} >> } >> >> message Request{ >> string request_message = 1; >> } >> >> message Response{ >> string response_message = 1; >> } >> >> >> Thanks, >> S Sathish Babu >> >> -- >> You received this message because you are subscribed to the Google Groups >> "grpc.io" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/grpc-io. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/grpc-io/4ce6fa34-b5a5-49d0-9296-b6c25cdc33ae%40googlegroups.com >> >> <https://groups.google.com/d/msgid/grpc-io/4ce6fa34-b5a5-49d0-9296-b6c25cdc33ae%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/2000128c-39d2-44ea-82f0-e9c5af3ed07e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
