Last active
May 9, 2021 22:49
-
-
Save mwakaba2/e76b0bc341bf17c97ff58cd4c672e4d4 to your computer and use it in GitHub Desktop.
Revisions
-
mwakaba2 revised this gist
May 9, 2021 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,17 +10,15 @@ async def test(): await run_sync(os.mkdir, 'test1') async def main(): await test() def clean_up(): try: os.rmdir('test1') except FileNotFoundError: pass -
mwakaba2 revised this gist
May 9, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ from anyio import run_sync_in_worker_thread as run_sync import asyncio async def test(): await run_sync(os.mkdir, 'test1') await run_sync(os.mkdir, 'test2') -
mwakaba2 revised this gist
May 9, 2021 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ import os try: from anyio.to_thread import run_sync except ImportError: # fallback on anyio v2 for python version < 3.7 from anyio import run_sync_in_worker_thread as run_sync import asyncio async def test(): await run_sync(os.mkdir, 'test1') @@ -15,13 +15,15 @@ async def test(): async def main(): await test() def clean_up(): try: os.rmdir('test1') os.rmdir('test2') except FileNotFoundError: pass if __name__ == '__main__': clean_up() loop = asyncio.get_event_loop() -
mwakaba2 created this gist
May 9, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import os import asyncio try: from anyio.to_thread import run_sync except ImportError: # fallback on anyio v2 for python version < 3.7 from anyio import run_sync_in_worker_thread as run_sync async def test(): await run_sync(os.mkdir, 'test1') await run_sync(os.mkdir, 'test2') async def main(): await test() def clean_up(): try: os.rmdir('test1') os.rmdir('test2') except FileNotFoundError: pass if __name__ == '__main__': clean_up() loop = asyncio.get_event_loop() loop.run_until_complete(main()) loop.close()