citusdata / django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus
MIT License
708 stars 116 forks source link

Updating docs to show the importance of unsetting the tenant in a middleware #173

Closed arpanpreneur closed 1 year ago

arpanpreneur commented 1 year ago

In the middleware example, it is assumed the user always has to have a tenant set. However, it is often better to unset the tenant in the middleware after the request is processed as it is using thread-local. As a rule of thumb, any thread-local should be cleared after request processing in a webserver because webservers reuse threads/processes.

arpanpreneur commented 1 year ago

@microsoft-github-policy-service agree

cristiangrojas commented 7 months ago

Hey!

I'd an issue I've been workin on for the last 5 days with no luck.

Just comed to this PR and it's definitely A MUST HAVE to avoid inconsistency in server responses.

Posted this question in StackOverflow I'll be updating with the solution soon