-
Notifications
You must be signed in to change notification settings - Fork 19
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
Now storing active schema in asgiref.local
#120
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…, as the current schema contains all the needed info
lorinkoz
changed the title
Major code revamp
Now storing active schema in Aug 27, 2022
asgiref.local
ey3ball
pushed a commit
to ey3ball/django-tenants
that referenced
this pull request
Aug 29, 2022
This fixes django-tenants#820 until a better method is found. The root cause is that information stored on connections is not available on all contexts during the processing of a request. In WSGI mode a single thread is involved so this is not visible. In ASGI mode however some code execute in the context of the async event loop. This is because the connection handler stores information in a thread_critical variable as seen here https://github.com/django/django/blob/main/django/utils/connection.py#L41. A better method would be to use asgi.local with our own sharing policy instead instead of attaching to the connexion object. Until that is settled (@lorinkoz has a prototype in lorinkoz/django-pgschemas#120) this patch modifies urlconf management in the subpath middleware. IO/connection operations which were previously done during resolve() are removed, which prevents the error from popping up in ASGI mode The downside is that we're modifying that we're generating a new urlconf object for each tenant. Also, this fixes a particular subpath issue, but does not address the more general issue of using connection to store a state accross each request processing.
ey3ball
pushed a commit
to ey3ball/django-tenants
that referenced
this pull request
Aug 29, 2022
This fixes django-tenants#820 until a better method is found. The root cause is that information stored on connections is not available on all contexts during the processing of a request. In WSGI mode a single thread is involved so this is not visible. In ASGI mode however some code execute in the context of the async event loop. This is because the connection handler stores information in a thread_critical variable as seen here https://github.com/django/django/blob/main/django/utils/connection.py#L41. A better method would be to use asgi.local with our own sharing policy instead instead of attaching to the connexion object. Until that is settled (@lorinkoz has a prototype in lorinkoz/django-pgschemas#120) this patch modifies urlconf management in the subpath middleware. IO/connection operations which were previously done during resolve() are removed, which prevents the error from popping up in ASGI mode The downside is that we're modifying that we're generating a new urlconf object for each tenant. Also, this fixes a particular subpath issue, but does not address the more general issue of using connection to store a state accross each request processing.
ktowen
approved these changes
Sep 7, 2022
fvallee-fbx
added a commit
to fvallee-fbx/django-tenants
that referenced
this pull request
Jun 5, 2023
This fixes django-tenants#820 until a better method is found. The root cause is that information stored on connections is not available on all contexts during the processing of a request. In WSGI mode a single thread is involved so this is not visible. In ASGI mode however some code execute in the context of the async event loop. This is because the connection handler stores information in a thread_critical variable as seen here https://github.com/django/django/blob/main/django/utils/connection.py#L41. A better method would be to use asgi.local with our own sharing policy instead instead of attaching to the connexion object. Until that is settled (@lorinkoz has a prototype in lorinkoz/django-pgschemas#120) this patch modifies urlconf management in the subpath middleware. IO/connection operations which were previously done during resolve() are removed, which prevents the error from popping up in ASGI mode The downside is that we're modifying that we're generating a new urlconf object for each tenant. Also, this fixes a particular subpath issue, but does not address the more general issue of using connection to store a state accross each request processing.
McDonnellJoseph
pushed a commit
to McDonnellJoseph/django-tenants
that referenced
this pull request
Jul 15, 2024
This fixes django-tenants#820 until a better method is found. The root cause is that information stored on connections is not available on all contexts during the processing of a request. In WSGI mode a single thread is involved so this is not visible. In ASGI mode however some code execute in the context of the async event loop. This is because the connection handler stores information in a thread_critical variable as seen here https://github.com/django/django/blob/main/django/utils/connection.py#L41. A better method would be to use asgi.local with our own sharing policy instead instead of attaching to the connexion object. Until that is settled (@lorinkoz has a prototype in lorinkoz/django-pgschemas#120) this patch modifies urlconf management in the subpath middleware. IO/connection operations which were previously done during resolve() are removed, which prevents the error from popping up in ASGI mode The downside is that we're modifying that we're generating a new urlconf object for each tenant. Also, this fixes a particular subpath issue, but does not address the more general issue of using connection to store a state accross each request processing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.