Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread safety #4

Open
ledermann opened this issue May 31, 2011 · 5 comments
Open

Thread safety #4

ledermann opened this issue May 31, 2011 · 5 comments

Comments

@ledermann
Copy link
Contributor

IMHO, using

attr_accessor :current_tenant

is not thread-safe. You should use

Thread.current[:current_tenant]

instead.

@priithaamer
Copy link

Can someone confirm this? I've been using acts_as_scoped in Rails 2.3 app over several years now. This plugin also uses attr_accessor to store the "current" scope object and it has been working fine so far.

@plentz
Copy link

plentz commented Dec 8, 2011

I pretty much dislike threadlocals, but I think that this is a good use.

@HakubJozak
Copy link

Hi! Is anyone still maintaining this gem? I really think it is thread-safe and anyone using it in production in multi-threaded env should be warned. Here is a quick test:

https://gist.github.com/HakubJozak/b00d577f1703ba28dc3cff1aec514626

@wireframe
Copy link
Owner

hey @HakubJozak, thanks for putting together the demo script and I'd be happy to fix any known issues. would you be interested in putting together a pull request to close this issue?

@sapanakothari
Copy link
Contributor

@wireframe PR to make multitenant thread-safe #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants