diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-01-30 15:53:27 -0500 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-01-31 08:59:54 -0500 |
| commit | 4a52533329a03207c1c4592a13fbb12b9ec5ef9e (patch) | |
| tree | d45724230dc3a299b1563418e2713cfc81450604 /docs/topics | |
| parent | 93dfb16e96797583a6f45eeb918e78c7f2817318 (diff) | |
Refs #34118 -- Removed asgiref coroutine detection shims.
As Python 3.12 is now the floor, we can drop the shims and
use the `inspect` module.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/async.txt | 4 | ||||
| -rw-r--r-- | docs/topics/http/middleware.txt | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/docs/topics/async.txt b/docs/topics/async.txt index 5cf9fd4624..2607381ad2 100644 --- a/docs/topics/async.txt +++ b/docs/topics/async.txt @@ -28,9 +28,9 @@ class-based view, this means declaring the HTTP method handlers, such as .. note:: - Django uses ``asgiref.sync.iscoroutinefunction`` to test if your view is + Django uses ``inspect.iscoroutinefunction`` to test if your view is asynchronous or not. If you implement your own method of returning a - coroutine, ensure you use ``asgiref.sync.markcoroutinefunction`` so this + coroutine, ensure you use ``inspect.markcoroutinefunction`` so this function returns ``True``. Under a WSGI server, async views will run in their own, one-off event loop. diff --git a/docs/topics/http/middleware.txt b/docs/topics/http/middleware.txt index 1c3b3c2a26..8bca89f56d 100644 --- a/docs/topics/http/middleware.txt +++ b/docs/topics/http/middleware.txt @@ -318,7 +318,7 @@ If your middleware has both ``sync_capable = True`` and ``async_capable = True``, then Django will pass it the request without converting it. In this case, you can work out if your middleware will receive async requests by checking if the ``get_response`` object you are passed is a -coroutine function, using ``asgiref.sync.iscoroutinefunction``. +coroutine function, using ``inspect.iscoroutinefunction``. The ``django.utils.decorators`` module contains :func:`~django.utils.decorators.sync_only_middleware`, @@ -337,7 +337,7 @@ at an additional performance penalty. Here's an example of how to create a middleware function that supports both:: - from asgiref.sync import iscoroutinefunction + from inspect import iscoroutinefunction from django.utils.decorators import sync_and_async_middleware @@ -373,7 +373,7 @@ Here's an example of how to create a middleware function that supports both:: When using an asynchronous class-based middleware, you must ensure that instances are correctly marked as coroutine functions:: - from asgiref.sync import iscoroutinefunction, markcoroutinefunction + from inspect import iscoroutinefunction, markcoroutinefunction class AsyncMiddleware: |
