Python gRPC multithreading

1,859 views
Skip to first unread message

Shraddha Thakkar

unread,
Aug 9, 2016, 8:43:00 PM8/9/16
to grpc.io
Hi,

I am implementing a gRPC server and client in python. My requirement is that the server continuously streams the system data to the client once the client establishes a connection, so I have implemented a server streaming (response streaming ) RPC call for this requirement.
The remaining RPC Calls need to work in parallel and so I have initiated a new thread on the client end just to receive the stream of data and the main thread executes the remaining RPC Calls required. 
But I observe the output to be gibberish so it seems I need to handle multiple simultaneous client requests on the server side, using tread pool or some other way. 
Please correct me if I am going wrong anywhere, and please suggest what can I do to handle multiple simultaneous client requests in my Python Implementation.

Nathaniel Manista

unread,
Aug 10, 2016, 8:06:45 PM8/10/16
to Shraddha Thakkar, grpc.io
On Tue, Aug 9, 2016 at 5:42 PM, Shraddha Thakkar <shrad...@gmail.com> wrote:
I am implementing a gRPC server and client in python. My requirement is that the server continuously streams the system data to the client once the client establishes a connection, so I have implemented a server streaming (response streaming ) RPC call for this requirement.
The remaining RPC Calls need to work in parallel and so I have initiated a new thread on the client end just to receive the stream of data and the main thread executes the remaining RPC Calls required.

This all sounds good so far...

But I observe the output to be gibberish so it seems I need to handle multiple simultaneous client requests on the server side, using tread pool or some other way.

Yes, a thread pool is required on the server. Consequently a thread pool is a required parameter of grpc.server. Are you not calling grpc.server to construct your server? Are you not passing a thread pool when you do?

Please correct me if I am going wrong anywhere, and please suggest what can I do to handle multiple simultaneous client requests in my Python Implementation.

I strongly suspect that you are going wrong somewhere, but it will be hard to determine exactly where without reading your code. Please share it with us?
-Nathaniel
Reply all
Reply to author
Forward
0 new messages