-
Notifications
You must be signed in to change notification settings - Fork 481
Description
With the increasing popularity of multi-threaded hosts, such as sidekiq and puma, plus the addition of rails 4.0 defaulting to thread-safe mode, it is becoming a limiting factor that this library is not thread safe.
The use of a class variable to store the site and auth token mean that if there are any concurrent requests on different threads these values will be overwritten and chaos may ensue.
I want to raise this issue here also because it has taken quite a while to figure out if the library is thread safe or not - and it's not an easy thing to test reliably. The best I can find is this post: http://ecommerce.shopify.com/c/shopify-apis-and-technology/t/threadsafety-shopify-api-gem-115828 . Reviewing the code and recent changes I believe the issue is still present.
A possible solution could be similar to the answer given in this question, and I'd like to know if this is applicable and a good idea for this library: http://stackoverflow.com/questions/8088126/is-it-thread-safe-to-set-active-resource-http-authentication-on-a-per-user-basis
edited: removed uncertainty - this library is not thread safe. As mentioned in comments ActiveResource has been updated so that the headers are now thread safe, however the session object and base.rb monkey patching still expose the issue.