Coverage for docs_src/tutorial/syncify/tutorial001.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 01:12 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 01:12 +0000
1import time 1abcde
3import anyio 1abcde
4from asyncer import asyncify, syncify 1abcde
7async def do_async_work(name: str): 1abcde
8 await anyio.sleep(1) 1abcde
9 return f"Hello, {name}" 1abcde
12def do_sync_work(name: str): 1abcde
13 time.sleep(1) 1abcde
14 message = syncify(do_async_work)(name=name) 1abcde
15 return message 1abcde
18async def main(): 1abcde
19 message = await asyncify(do_sync_work)(name="World") 1abcde
20 print(message) 1abcde
23anyio.run(main) 1abcde