Skip to content

This library is not thread safe #52

@bradrees

Description

@bradrees

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions