python support multi-thread

47 views
Skip to first unread message

rob.vai...@gmail.com

unread,
Oct 25, 2018, 12:11:49 PM10/25/18
to grpc.io
hi
 
I want to know Is grpc python support multi-thread?

Carl Mastrangelo

unread,
Oct 26, 2018, 2:16:33 PM10/26/18
to grpc.io
Yes it does.  If you provide more information about what you want to do, we can give a better answer.

Vaibhav Bedi

unread,
Oct 26, 2018, 2:21:26 PM10/26/18
to not...@google.com, grp...@googlegroups.com
My problem is
I want to write the grpc python multithread code for the client-server application, both client and server should use
threads in order to handle multi-requests at the same time. The client is simulating a gateway where it uploads data to the server. This data should be an array of objects.
The server is receiving these data and printing them in a multi-threaded way.

Thank you

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/TYz7WUUJkiw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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/31b617e5-629f-473b-8dcf-d9af2d17a0a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Sincerely,
Vaibhav Bedi
Contact Number-8950597710

Vaibhav Bedi

unread,
Oct 26, 2018, 2:23:52 PM10/26/18
to not...@google.com, grp...@googlegroups.com
Can you share some reference?

Carl Mastrangelo

unread,
Oct 26, 2018, 2:27:51 PM10/26/18
to rob.vai...@gmail.com, Lidi Zheng, grp...@googlegroups.com
+Lidi

Srini Polavarapu

unread,
Oct 26, 2018, 4:35:24 PM10/26/18
to grpc.io
On the server you can provide a threadpool like this: 
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))

This will spawn a maximum of 10 concurrent threads to handle requests in parallel. See this example: https://github.com/grpc/grpc/blob/master/examples/python/helloworld/greeter_server.py

On the client side, you can create one channel and pass it to your worker threads to create stubs on that channel. Worker threads can then do concurrent RPCs on their own stubs while using the same channel (connection) to the server.

Vaibhav Bedi

unread,
Oct 27, 2018, 9:13:45 AM10/27/18
to psr...@google.com, grp...@googlegroups.com
Thanks for your help. Can you suggest me how to pass an array of objects to the server in grpc?
I saw most of the examples they are using only string.


For more options, visit https://groups.google.com/d/optout.

Robert Engels

unread,
Oct 27, 2018, 9:55:07 AM10/27/18
to Vaibhav Bedi, psr...@google.com, grp...@googlegroups.com
I believe if you declare the data as repeated it will automatically use arrays in the bindings. 
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 grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Vaibhav Bedi

unread,
Oct 27, 2018, 10:06:42 AM10/27/18
to ren...@earthlink.net, psr...@google.com, grp...@googlegroups.com
When I sent the objects using strings.there is no internal mechanism to sent that data in objects. it's giving an error.

Vaibhav Bedi

unread,
Oct 27, 2018, 11:45:28 AM10/27/18
to ren...@earthlink.net, psr...@google.com, grp...@googlegroups.com
can you share some reference link how I can write an array of objects in the .proto file?

Robert Engels

unread,
Oct 27, 2018, 3:37:20 PM10/27/18
to Vaibhav Bedi, psr...@google.com, grp...@googlegroups.com
Grpc is not serialization. You don’t write objects. You declare messages and they can be repeated. 

Sent from my iPhone

Vaibhav Bedi

unread,
Oct 27, 2018, 3:46:29 PM10/27/18
to Robert Engels, psr...@google.com, grp...@googlegroups.com
can I define the message only in strings not array?

Robert Engels

unread,
Oct 27, 2018, 3:47:42 PM10/27/18
to Vaibhav Bedi, psr...@google.com, grp...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages