Skip to content

Instantly share code, notes, and snippets.

@mwakaba2
Last active May 9, 2021 22:49
Show Gist options
  • Save mwakaba2/e76b0bc341bf17c97ff58cd4c672e4d4 to your computer and use it in GitHub Desktop.
Save mwakaba2/e76b0bc341bf17c97ff58cd4c672e4d4 to your computer and use it in GitHub Desktop.
Script to reproduce the `AsyncLibraryNotFoundError` error.
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