asyncify() — anthropic-sdk-python Function Reference
Architecture documentation for the asyncify() function in _sync.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 0cf43326_8958_e075_23bd_639f762e2a70["asyncify()"] 3d1d47e4_c6e3_27f4_3ae5_5b770d5eec83["_sync.py"] 0cf43326_8958_e075_23bd_639f762e2a70 -->|defined in| 3d1d47e4_c6e3_27f4_3ae5_5b770d5eec83 a59a3f56_0145_926b_7f5e_8c49b5353e5a["to_thread()"] 0cf43326_8958_e075_23bd_639f762e2a70 -->|calls| a59a3f56_0145_926b_7f5e_8c49b5353e5a style 0cf43326_8958_e075_23bd_639f762e2a70 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_utils/_sync.py lines 28–58
def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
"""
Take a blocking function and create an async one that receives the same
positional and keyword arguments.
Usage:
```python
def blocking_func(arg1, arg2, kwarg1=None):
# blocking code
return result
result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
```
## Arguments
`function`: a blocking regular callable (e.g. a function)
## Return
An async function that takes the same positional and keyword arguments as the
original one, that when called runs the same original function in a thread worker
and returns the result.
"""
async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
return await to_thread(function, *args, **kwargs)
return wrapper
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does asyncify() do?
asyncify() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_utils/_sync.py.
Where is asyncify() defined?
asyncify() is defined in src/anthropic/_utils/_sync.py at line 28.
What does asyncify() call?
asyncify() calls 1 function(s): to_thread.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free