Coverage for docs_src/tutorial/syncify_no_raise/tutorial001.py: 100%
18 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, raise_sync_error=False)(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
23def sync_main(): 1abcde
24 message = do_sync_work(name="Sync World") 1abcde
25 print(message) 1abcde
28anyio.run(main) 1abcde
29sync_main() 1abcde