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

Why PGThread neccesary? #93

Closed
kissgyorgy opened this issue Nov 14, 2013 · 2 comments · Fixed by #94
Closed

Why PGThread neccesary? #93

kissgyorgy opened this issue Nov 14, 2013 · 2 comments · Fixed by #94

Comments

@kissgyorgy
Copy link
Contributor

https://github.com/bernardopires/django-tenant-schemas/blob/master/tenant_schemas/postgresql_backend/base.py#L22

I'm just learning about threading and I hope someone will answer this for me: Why is PGThread class neccesary? What is exactly doing?
It's strange because as I understand Django connections are implemented as thread locals, so schema, tenant could be set on the connection itself, no?

@bernardopires
Copy link
Owner

You always have excellent questions! 👍

I've been looking at django's code and at my code the last 45 minutes and can't think of any good reason. I even found the commit where I added this class e8e395a. To be honest I have no recollection of why this was needed. The comment on the class also doesn't make much sense "This is a bad monkey patching resulting from the fact that we can't separate public from shared apps right now. issue #1 on github". Maybe at that time I didn't know I could have used the connections as thread locals?

I'm always in favor of refactoring code that doesn't make sense. Do you want to send a patch?

@kissgyorgy
Copy link
Contributor Author

Sure!

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

Successfully merging a pull request may close this issue.

2 participants