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

Add async tests #1835

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add async tests #1835

wants to merge 4 commits into from

Conversation

salomvary
Copy link
Contributor

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.

Copy link
Contributor

@tim-schilling tim-schilling left a 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.

example/README.rst Show resolved Hide resolved
example/settings.py Show resolved Hide resolved
Comment on lines +116 to +117
# Log when an asynchronous handler is adapted for middleware.
# See warning here: https://docs.djangoproject.com/en/4.2/topics/async/#async-views
Copy link
Contributor

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?

Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

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 this pull request may close these issues.

None yet

3 participants