diff options
Diffstat (limited to 'docs')
| -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: |
