Closed aryx closed 1 year ago
cc @quernd
Or is it a limitation of Grpc_lwt and to get more flexibility I should use Grpc_eio?
Thanks for reporting this! It is not a limitation of neither Lwt nor server_streaming, but the example. The client code reads the entire stream first and turns it into a list before logging anything. If you add logs inside Lwt_stream.map
you will see each message when it comes in.
Also, in this specific case, you will want to use a nonblocking sleep
instead of Unix.sleep
. Otherwise the server will execute the entire loop without allowing a context switch to allow IO to happen.
Both is demonstrated in this commit.
In general, Grpc_eio is the future and probably just as mature or immature as the other backends at this point, so if you can, try it out!
@aryx Do you think that the example could be clearer about the LWT behaviour? What could we improve to make it better?
I noticed that the async
implementation of route guide prints out the responses as they appear at the client, while the other two implementations read the entire stream first and then print it out. That should get fixed so they all work the same.
I think just merge the commit quend linked above so all implem do the same and prints out responses as they appear at the client.
Closing as switching to grpc-eio solves my issue too.
Hi,
I have a server that I would like to serve a stream of response where each takes a long time to compute, and I would like a client that gradually display those responses, as soon as they arrive.
I've modified the routeguide-lwt example in the ocaml-grpc repo with this diff:
unfortunately when I run in one terminal
and in the other
even though the server seems to gradually compute the response (the server output progress on stdout), the client seems blocked on SERVER_STREAMING, and need to wait for all responses to be computed to finally print all of them at once.
Is there a way to fix the server or the client to gradually display the responses? Is Server_streaming the right way to solve this problem? Or I need to use bidirectional streaming?