Home / Function/ async_to_sync() — flask Function Reference

async_to_sync() — flask Function Reference

Architecture documentation for the async_to_sync() function in app.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  932db8de_227d_6d62_8474_b93b49f1ed96["async_to_sync()"]
  9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"]
  932db8de_227d_6d62_8474_b93b49f1ed96 -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5
  a89c0022_4807_bf16_9be1_6a66f3c78c9f["ensure_sync()"]
  a89c0022_4807_bf16_9be1_6a66f3c78c9f -->|calls| 932db8de_227d_6d62_8474_b93b49f1ed96
  style 932db8de_227d_6d62_8474_b93b49f1ed96 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/app.py lines 1078–1099

    def async_to_sync(
        self, func: t.Callable[..., t.Coroutine[t.Any, t.Any, t.Any]]
    ) -> t.Callable[..., t.Any]:
        """Return a sync function that will run the coroutine function.

        .. code-block:: python

            result = app.async_to_sync(func)(*args, **kwargs)

        Override this method to change how the app converts async code
        to be synchronously callable.

        .. versionadded:: 2.0
        """
        try:
            from asgiref.sync import async_to_sync as asgiref_async_to_sync
        except ImportError:
            raise RuntimeError(
                "Install Flask with the 'async' extra in order to use async views."
            ) from None

        return asgiref_async_to_sync(func)

Subdomains

Defined In

Called By

Frequently Asked Questions

What does async_to_sync() do?
async_to_sync() is a function in the flask codebase, defined in src/flask/app.py.
Where is async_to_sync() defined?
async_to_sync() is defined in src/flask/app.py at line 1078.
What calls async_to_sync()?
async_to_sync() is called by 1 function(s): ensure_sync.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free