-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
errors thrown when sending emails within multiple threads #90
Comments
Thank you for reporting this issue. There appears to be a thread-safety issue with how the service interfaces (e.g.
Please watch this issue for updates. |
@trevorrowe, thanks for the response, but please note that keeping the initialization out of the loop will still have the same issue. ~/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/aws-sdk-1.7.1/lib/aws/core/signature/version_4.rb:87:in `service': NotImplementedError (NotImplementedError) ~/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/aws-sdk-1.7.1/lib/aws/core/client.rb:499:in |
Given the following example require 'aws-sdk'
ses = AWS::SimpleEmailService.new # loading credentials from environment
pool = Array.new(10) do |i|
Thread.new do
ses.send_email(
:subject => 'subject',
:body_html => 'body_html',
:body_text => 'body_text',
:to => 'success@simulator.amazonses.com',
:from => 'some@email.com', # replace this with a verified email address
)
end
end
pool.each(&:join) I was able to execute this many times without issue. If I moved the ses assignment inside the Thread.new block, then it would fail every time due to thread safety issues. Is this what your test example looks like? |
@trevorrowe, I've been able to execute it multiple times without issue as well, but If I keep at it I do get the occasional add_authorization error. Havn't been able to reproduce the error at "version_4.rb:87" again though. My test file is exactly the same except for the array size which I've set to 90 and of course the from email. |
@desheikh I just pushed a commit that resolves an issue with AWS::Core::Configuration. I then took your original example and added one line. Between the two, this resolved the issue for me. AWS.eager_autoload! I realize this is not an ideal fix. It forcibly loads all AWS classes up-front, which can be slow, but it is a one-time cost. That said, this is not an issue in Ruby 2.0 and you can drop the call to eager_autoload! if you are able to upgrade. |
Closing this issue as it should work properly if all classes have been eagerly auto-loaded. Please re-open if you still run into issues. |
Hi, |
tested using ruby 1.9.3-p327
~/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/aws-sdk-1.7.1/lib/aws/core/client.rb:499:in
build_request': undefined method
add_authorization!' for #AWS::SimpleEmailService::Request:0x007feac892bd90 (NoMethodError)~/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/aws-sdk-1.7.1/lib/aws/simple_email_service.rb:281:in
send_email': undefined method
send_email' for #AWS::SimpleEmailService::Client:0x007fdf7c1465c8 (NoMethodError)The text was updated successfully, but these errors were encountered: