Path 1: 20 calls (1.0)

_async_app..index def (4) _async_app..bp_index def (2) AsyncView.dispatch_request def (2) test_async_before_after_request..bef...

AsyncToSync (20)

1def async_to_sync(
2        self, func: t.Callable[..., t.Coroutine]
3    ) -> t.Callable[..., t.Any]:
4        """Return a sync function that will run the coroutine function.
5
6        .. code-block:: python
7
8            result = app.async_to_sync(func)(*args, **kwargs)
9
10        Override this method to change how the app converts async code
11        to be synchronously callable.
12
13        .. versionadded:: 2.0
14        """
15        try:
16            from asgiref.sync import async_to_sync as asgiref_async_to_sync
17        except ImportError:
18            raise RuntimeError(
19                "Install Flask with the 'async' extra in order to use async views."
20            ) from None
21
22        return asgiref_async_to_sync(func)