-
First Check
Commit to Help
Example Codeimport time
from typing import reveal_type
import anyio
from asyncer import asyncify
@asyncify
def do_sync_work(name: str):
time.sleep(1)
return f"Hello, {name}"
async def main():
message = await do_sync_work(name="World")
reveal_type(do_sync_work) # Type of "do_sync_work" is "(name: str) -> Awaitable[str]"
reveal_type(message) # Type of "message" is "str"
anyio.run(main) DescriptionAll Operating SystemWindows Operating System DetailsNo response asyncer Version0.0.5 Python VersionPython 3.11.8 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
tiangolo
Aug 24, 2024
Replies: 1 comment
-
It's because decorating a function with |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tiangolo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's because decorating a function with
asyncify
would make it only awaitable, it wouldn't be callable from blocking code, while the logic and code underneath are purely sync. And documenting it could encourage it, while it's probably not ideal, so I prefer not to document it.