3 ms·
You don’t need two different mains. My asyncio code runs just fine on both and didn’t require changes when moving from 3.10 to 3.11 possibly because the way I a
by seanhunter 4y ago
You don’t need two different mains. My asyncio code runs just fine on both and didn’t require changes when moving from 3.10 to 3.11 possibly because the way I always do it is asyncio.run(main()) from the body of the code (“actual main”) to an
async def main
async callable and the last real line of that is pretty much always just an asyncio.gather over a bunch of other stuff that I want to run. My understanding is that’s been the recommended method for a very long time rather than get_event_loop or run_forever or anything like that.
edit: that is to say, asyncio.run() may be required now but the method of injecting coroutines and then doing run_forever was definitely not required before. Asyncio.run was available before 3.11.