Closed 9mm closed 4 years ago
No it's not. I haven't dug to see if there are more reasons why it's not, but one is that the request
that's built and the http
client are attributes of the client-wrapper: https://github.com/sendgrid/ruby-http-client/blob/master/lib/ruby_http_client.rb#L86
So you'll need a SendGrid::API.new
instance for each thread.
@childish-sambino ah, interesting... so I'm not an expert in threadsafe code (I just switched to Sidekiq so I'm trying to learn). Can you explain why the attr_reader line isn't thread safe? I thought that makes instance variables which are threadsafe as long as .new
is instantiated for each thread?
What I meant is that you can't use the same SendGrid::API
instance across multiple threads. But yes, if each thread uses a .new
instance then it should be safe.
Hello, is this gem threadsafe? I was wanting to use it inside Sidekiq.
Thanks!