The asyncio.run() function is used to run the top-level entry point of an asyncio program. It should generally only be called once per program.
Calling it multiple times can lead to unexpected behavior:
import asyncio
async def main():
print("Hello")
asyncio.run(main())
asyncio.run(main()) # Probably won't work as expected
When
So calling it a second time tries to create and close a new event loop while the existing one may still be open.
Here are some tips on using
So in summary,
Related articles:
Browse by tags:
Browse by language:
Popular articles:
- Web Scraping in Python - The Complete Guide
- Working with Query Parameters in Python Requests
- How to Authenticate with Bearer Tokens in Python Requests
- Building a Simple Proxy Rotator with Kotlin and Jsoup
- The Complete BeautifulSoup Cheatsheet with Examples
- The Complete Playwright Cheatsheet
- Web Scraping using ChatGPT - Complete Guide with Examples