-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZMQError: Operation cannot be accomplished in current state #29
Comments
This is due to multi-threading. Without multi-threading on client-side, this error does not appear anymore. Note : |
hi, just fyi, the client-side supports multi-thread/process. that’s part of the design principle. It’s just that you can’t reuse a BertClient in multiple threads/processes. For example: BADbc = BertClient()
# in Proc1/Thread1 scope:
bc.encode(lst_str)
# in Proc2/Thread2 scope:
bc.encode(lst_str) Instead, please do: GOOD# in Proc1/Thread1 scope:
bc1 = BertClient()
bc1.encode(lst_str)
# in Proc2/Thread2 scope:
bc2 = BertClient()
bc2.encode(lst_str) |
i think this is a quite common issue, will add this to faq |
Thanks for the clarification. One last question : Which one is better ?
|
@colanim I believe this is close to what you need https://github.com/hanxiao/bert-as-service/blob/afe66168b45053e7052a102c396e8e2e70e1a744/example4.py#L33-L37 In this example, bert-as-service is used within tf.data, which I'm currently working on, therefore in a separate branch. The trick is making multiple Note that there is a pending bug when making multiple |
So, if I understand well, I need to work with a pool of |
yes, |
I did as you said, and it works like a charm ! For those who are interested, here is my code in Keras for multi-threaded. The
As you can see, before calling the In my training script, I simply create a Queue of BertClient (among other things like retrieving the dataset):
And the actual training :
|
fyi, from 1.7.3 you can directly use Again |
When running client side, I encounter this error :
zmq.error.ZMQError: Operation cannot be accomplished in current state
Any idea of how to solve this ? Thanks !
On server side, everything seems fine :
Full stack :
The text was updated successfully, but these errors were encountered: