Last active
May 9, 2021 22:49
-
-
Save mwakaba2/e76b0bc341bf17c97ff58cd4c672e4d4 to your computer and use it in GitHub Desktop.
Script to reproduce the `AsyncLibraryNotFoundError` error.
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 characters
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') | |
async def main(): | |
await test() | |
def clean_up(): | |
try: | |
os.rmdir('test1') | |
except FileNotFoundError: | |
pass | |
if __name__ == '__main__': | |
clean_up() | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment