Closed CrazyUmka closed 11 months ago
Thank you for the report. I haven't been able to reproduce the problem because you didn’t provide enough details, but I have a proposed fix in #382. Please can you test it?
When you turn on asgi mode in Django using
daphne
we get error message in middleware chain.
Please provide the error message with the stack trace.
After that, you get next error: object HttpResponse can't be used in 'await' expression
Please provide the stack trace.
instead of
_is_coroutine
there should be an attribute_is_coroutine_marker
. To fix this, you can use themarkcoroutinefunction
I see this changed in Python 3.12. Thanks.
or the MiddlewareMixin class to support backwards compatibility.
The middleware deliberately doesn't use that class, which would make it slower because it uses sync_to_async
.
Python Version
3.12.0
Django Version
4.2.6
Django 4.2.6 doesn’t currently support Python 3.12. The only supported versions are those listed in the release notes page: https://docs.djangoproject.com/en/4.2/releases/4.2/ . The tracking ticket: https://code.djangoproject.com/ticket/34118 . You will likely encounter other incompatibility issues, especially so early into Python 3.12's release cycle.
I also made an optimization PR on Django, following investigation into the changes to MiddlewareMixin
: https://github.com/django/django/pull/17402 .
Python Version
3.12.0
Django Version
4.2.6
Package Version
1.17.0
Description
When you turn on asgi mode in Django using
daphne
we get error message in middleware chain. This happens because Django uses the following functionasgi.sync.markcoroutinefunction
to mark whether a coroutine is present or not. In here https://github.com/adamchainz/django-htmx/blob/235499211b93920caecafbc208a85231f9f4e339/src/django_htmx/middleware.py#L33 instead of_is_coroutine
there should be an attribute_is_coroutine_marker
. To fix this, you can use themarkcoroutinefunction
or theMiddlewareMixin
class to support backwards compatibility.Example of configuration to reproduce behavior
After that, you get next error:
object HttpResponse can't be used in 'await' expression