Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
ZMQError: Operation cannot be accomplished in current state #29
When running client side, I encounter this error :
Any idea of how to solve this ? Thanks !
On server side, everything seems fine :
Full stack :
This is due to multi-threading. Without multi-threading on client-side, this error does not appear anymore.
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:
bc = BertClient() # in Proc1/Thread1 scope: bc.encode(lst_str) # in Proc2/Thread2 scope: bc.encode(lst_str)
Instead, please do:
# in Proc1/Thread1 scope: bc1 = BertClient() bc1.encode(lst_str) # in Proc2/Thread2 scope: bc2 = BertClient() bc2.encode(lst_str)
Thanks for the clarification.
One last question :
Which one is better ?
@Colanim I believe this is close to what you need
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
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.
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 :