-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add async tests #1835
base: main
Are you sure you want to change the base?
Add async tests #1835
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply on this. Thank you for creating this PR!
I wonder if we could test this functionality by starting up runserver
with the asgi application, then using a separate selenium test against that rather than using the Django test runner.
# Log when an asynchronous handler is adapted for middleware. | ||
# See warning here: https://docs.djangoproject.com/en/4.2/topics/async/#async-views |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't fully understand the purpose here. Can you help me understand this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning the user when having to switch from async to sync in the middleware/view stack makes a lot of sense.
I'm not 100% sure if that has to be a part of django-debug-toolbar's example settings though. Is it necessary to define LOGGING
at all? Isn't it the default behavior already to emit those warnings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows surfacing the fact that django-debug-toolbar is not an async middleware, therefore Django needs to some extra stuff when using async views.
Probably only relevant until django-debug-toolbar becomes an async middleware.
Shall we remove from the example then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my vote is remove it or keep it but default it to DEBUG so that we get that logging you mention.
As discussed with @tim-schilling in #1828 a good start towards adding async support is adding tests involving async views and async ORM usage.
Unfortunately, none of the automated tests showcase the problem described in #1828 as there is no ASGI equivalent of
LiveServerTestCase
and the issue seems to be specific to running an actual ASGI server.Therefore, despite all tests are green, async support is still not there. Running the example app with an ASGI server using
ASYNC_SERVER=true python example/manage.py runserver
and visiting http://127.0.0.1:8000/async/db-concurrent/ does exhibit the deadlock though.See also #1819.