You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It may just be a matter of documentation to address this, but the way the documentation recommends setting Her up (with a single instance of Her::API) is not thread-safe because it uses a class instance variable, default_api, to store the instance created, and that instance's connection is shared for all threads (not safe) :)
We should either add some documentation about how to use this in a thread-safe way (i.e. create a new instance of Her::API for each thread using Thread.current[:my_api] = API.new(...)), or do that for the user automatically by storing @default_api as a thread-local variable, and regenerate it for each thread automatically rather than using a class instance variable.
The text was updated successfully, but these errors were encountered:
Thanks Joe - we should probably refactor so it’s threadsafe really. If you wanted to have a crack at putting a PR together that would be brilliant. Even just a PR for the readme to include some notes on the workaround would be appreciated :-).
It may just be a matter of documentation to address this, but the way the documentation recommends setting
Her
up (with a single instance ofHer::API
) is not thread-safe because it uses a class instance variable, default_api, to store the instance created, and that instance's connection is shared for all threads (not safe) :)We should either add some documentation about how to use this in a thread-safe way (i.e. create a new instance of
Her::API
for each thread usingThread.current[:my_api] = API.new(...)
), or do that for the user automatically by storing@default_api
as a thread-local variable, and regenerate it for each thread automatically rather than using a class instance variable.The text was updated successfully, but these errors were encountered: