-
Notifications
You must be signed in to change notification settings - Fork 3
Deluge of errors when making concurrent translate requests #6
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
Comments
Thanks for the report! There is some discussion on this in #3 . I don't think the keepalive support I added in 3.0 is possible without such errors with |
We also encountered these when using Threads to translate a list of texts with different contexts each. If you're looking for a recommendation: I'm quite happy with the http gem. I found it to be more robust than |
We had to go back to 3.2.0 just for the debounce/retry logic, because 2.5.3 keeps running into HTTP 429 when translating many texts. Background: Occasionally, we are translating about 100 texts, but in chunks of ~5 texts which each have their own translation context, so we cannot batch all 100 texts together into a single request. We saw much better performance sending requests in parallel using threads, instead of sending them on a single keepalive session. We can't prepare those transactions up front, since they happen on user interaction, which is why we care about performance. So, at least for the time being, we are patching the gem's DeepL::API.prepend(Module.new do
def http_client
Thread.current[:deepl_api_http_client_copy] ||= @http_client.dup
end
end) I'm aware that If anyone else wants to use the monkey-patch above, I suggest also checking the gem version so can verify if the patch is still required for newer releases. Example: if Gem.loaded_specs['deepl-rb'].version > Gem::Version.new('3.2.0')
raise ...
else
DeepL::API.prepend(...)
end |
At my work, last year we tried to upgrade to 3.x but had to downgrade for the same reason as reported here. We're staying on 2.x for the time being. |
Hey! Just wondering if there are any fixes in progress or we should resort to the monkey-patch posted above? |
Hi all, any news on this? I am running into the same problems with Rails 8 and solidqueue, which translates in parallel running threads. Do you recommend downgrading to 2.5.3 or is there a better option? At the moment we are running our jobs with the following queue config in rails:
which avoids the error, although it forces the jobs into sequential order. |
If you need concurrent requests, you'll need to downgrade to 2.5.3 atm, sorry. I'll try to fit in improvements to CLs into our coming sprints, we're just mostly working on API features at the moment, and our other (larger) libraries don't even have any async support at the moment. |
Thanks @JanEbbing |
From a technical standpoint, you should be fine using version 3.2 and caching the HTTP client instance once per thread, instead of globally by using the monkey patch from #6 (comment). The increased memory footprint should be barely noticable and it allows for using v3 features. (Still, I'd prefer an official solution to a monkey patch. 🙂) |
We have been using the gem on version 2.5.3 without any issues. However, we are now trying to update to the newest version, 3.0.2 and are facing quite a few issues
When making many ~10+ simultaneous translation requests via
DeepL.translate
from within sidekiq workers running in parallela lot of the requests fail and raise an error with either
IOError: stream closed in another thread
FrozenError: can't modify frozen OpenSSL::SSL::SSLContext
This was NOT an issue on 2.5.3
VERSION: 3.0.2
API CALL: `DeepL.translate("some string", nil, "FR", tag_handling: 'html')
The text was updated successfully, but these errors were encountered: