Giter Club home page Giter Club logo

Comments (7)

trevorrowe avatar trevorrowe commented on May 23, 2024

Thank you for reporting this issue. There appears to be a thread-safety issue with how the service interfaces (e.g. AWS::SimpleEmailService) construct their client. I will try to resolve this issue soon, but you should be able to work around this by constructing the ses interface outside the loop:

require 'aws-sdk'
ses = AWS::SimpleEmailService.new(...)
pool = Array.new(10) do |i|
Thread.new do
  ses.send_email(
    :subject => 'subject',
    :body_html => 'body_html',
    :body_text => 'body_text',
    :to => '[email protected]',
    :from => '[email protected]',
  )
  end
end

pool.each(&:join)

Please watch this issue for updates.

from aws-sdk-ruby.

desheikh avatar desheikh commented on May 23, 2024

@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 build_request': undefined methodadd_authorization!' for #AWS::SimpleEmailService::Request:0x007fdff13558d0 (NoMethodError)

from aws-sdk-ruby.

trevorrowe avatar trevorrowe commented on May 23, 2024

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 => '[email protected]',
    :from => '[email protected]', # 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?

from aws-sdk-ruby.

desheikh avatar desheikh commented on May 23, 2024

@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.

from aws-sdk-ruby.

trevorrowe avatar trevorrowe commented on May 23, 2024

@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.

from aws-sdk-ruby.

trevorrowe avatar trevorrowe commented on May 23, 2024

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.

from aws-sdk-ruby.

desheikh avatar desheikh commented on May 23, 2024

Hi,
Thanks, I just tested out sending mails out with the latest version of the sdk and so far have not experienced any issues yet even without the eager_autoload.
AWS.eager_autoload! raises an exception though, created a separate issue for it.

from aws-sdk-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.