Home / Function/ noop_wrap_async() — fastapi Function Reference

noop_wrap_async() — fastapi Function Reference

Architecture documentation for the noop_wrap_async() function in test_dependency_wrapped.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  1a9a2fbb_703e_24d8_8ab4_cc62573b574b["noop_wrap_async()"]
  23108d30_2765_dee1_a01d_c92aecd86c64["test_dependency_wrapped.py"]
  1a9a2fbb_703e_24d8_8ab4_cc62573b574b -->|defined in| 23108d30_2765_dee1_a01d_c92aecd86c64
  style 1a9a2fbb_703e_24d8_8ab4_cc62573b574b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_dependency_wrapped.py lines 25–55

def noop_wrap_async(func):
    if inspect.isgeneratorfunction(func):

        @wraps(func)
        async def gen_wrapper(*args, **kwargs):
            async for item in iterate_in_threadpool(func(*args, **kwargs)):
                yield item

        return gen_wrapper

    elif inspect.isasyncgenfunction(func):

        @wraps(func)
        async def async_gen_wrapper(*args, **kwargs):
            async for item in func(*args, **kwargs):
                yield item

        return async_gen_wrapper

    @wraps(func)
    async def wrapper(*args, **kwargs):
        if inspect.isroutine(func) and iscoroutinefunction(func):
            return await func(*args, **kwargs)
        if inspect.isclass(func):
            return await run_in_threadpool(func, *args, **kwargs)
        dunder_call = getattr(func, "__call__", None)  # noqa: B004
        if iscoroutinefunction(dunder_call):
            return await dunder_call(*args, **kwargs)
        return await run_in_threadpool(func, *args, **kwargs)

    return wrapper

Domain

Subdomains

Frequently Asked Questions

What does noop_wrap_async() do?
noop_wrap_async() is a function in the fastapi codebase, defined in tests/test_dependency_wrapped.py.
Where is noop_wrap_async() defined?
noop_wrap_async() is defined in tests/test_dependency_wrapped.py at line 25.

Analyze Your Own Codebase

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

Try Supermodel Free