Open leecodedog opened 7 years ago
Well, gevent and threads do not play nice together. You should use
cooperative coroutines instead via gevent.spawn
.
You can still use threads, but you cannot share a zerorpc context across them. You could use zerorpc to talk via in memory IPC. Making sure to have one zerorpc context per thread. Or you can communicate between threads using a queue designed for this purpose. I believe gevent offers something, check the doc.
Multithreading is not the best in Python because of the global interpreter lock. Only C libraries used from Python will really run concurrently. However you can also start multiples processes. And have them communicate via zerorpc.
best -- fx
On Sun, May 7, 2017, 20:22 leecodedog notifications@github.com wrote:
when I use multithreading or multiprocess client,just like: thread.start_new_thread(client.func, ())
I got nothing ! Is there skill to use multithreading client ?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/0rpc/zerorpc-python/issues/163, or mute the thread https://github.com/notifications/unsubscribe-auth/AANMjAp42ZdE9avlG-Pg6cHKWgPexgGKks5r3oqDgaJpZM4NTcGU .
Thank you, It is really cause by gevent. I used thread.local() to fix it finall . By the way, I met this problem when flask in mutithread state. To fix it, I write a flask-ext to fix it. If you could see it, I will be very honored Flask-Ext-ZeroRpcClient
Flask is blocking the python thread. You can use gunicorn to run flask in a gevent environment.
On Thu, Sep 14, 2017, 18:29 leecodedog notifications@github.com wrote:
Thank you, It is really cause by gevent. I used thread.local() to fix it finall . By the way, I met this problem when flask in mutithread state. To fix it, I write a flask-ext to fix it. If you could see it, I will be very honored https://github.com/leecodedog/Flask-Ext-ZeroRpcClient http://Flask-Ext-ZeroRpcClient
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/0rpc/zerorpc-python/issues/163#issuecomment-329652243, or mute the thread https://github.com/notifications/unsubscribe-auth/AANMjFD1YffZIuoG8-qnSuwLEOtd_xwJks5sidMQgaJpZM4NTcGU .
when I use multithreading or multiprocess client,just like:
thread.start_new_thread(client.func, ())
I got nothing ! Is there skill to use multithreading client ?