Stories from the Web Crawling trenches in control

How many times should asyncio run () be called python ?

Author: Mohan Ganesan

Date: Mar 17, 2024

The 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. Here are some tips on using Call it only once at the top level of your program. Use in simple programs and scripts. If you do call multiple times, make sure the event loop from the previous call is fully closed first.

Tired of getting blocked while scraping the web?

ProxiesAPI handles headless browsers and rotates proxies for you.
Get access to 1,000 free API credits, no credit card required!