0

I have a gRPC server on Go Lang and the client is in python. I have one RPC call in which the client initiates a progress stream and after completing the progress it sends a completion message to the server that the stream is finished.

The problem is the client is initiating the stream and committing to every call. I want to send a completion message when the progress reaches 100%.

Here is my RPC call:

service DownloadClient{

    rpc Progress (stream ProgressMessage) returns (google.protobuf.Empty);
}

message ProgressMessage{
    double progress = 1;
}

The client code:

def sendProgress():
    p = 0
    while p <= 100:
        sleep(1)
        client.Progress(progressMessage(p).send(None))
        p=p+1


def progressMessage(value=0):
        prog = mypb.Progress(progress=value)

        yield prog

sendProgress()

1 Answer 1

0

I think something is wrong in your code. focusing on this line

client.Progress(progressMessage(p).send(None))

what is it trying to achieve? AFAIU this should look more like

client.Progress(progressMessage(p))
# where client is a class that has a stub that calls the rpc
# i.e.
# class SomeClient:
#   def Progress(self, the_stream):
#       self.stub.Progress(the_stream)
#

see also https://grpc.io/docs/languages/python/basics/#calling-service-methods

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.