2 ms·
We are getting there. asyncio in 3.7 is now quite ok to use. Plus, I'm working with andrew sveltov on a new API for aiohttp, so that you can do: def main(
by BiteCode_dev 7y ago
We are getting there. asyncio in 3.7 is now quite ok to use.
Plus, I'm working with andrew sveltov on a new API for aiohttp, so that you can do:
def main():
response = await aiohttp.get(url)
asyncio.run(main())
It should make at least the most common use case of asyncio way more easier.
The biggest problem is that I have yet seen a tutorial that explains properly how to use asyncio.
They all talk about the loop, and future, etc..
First, they all should tell you that asyncio should be used only with Python 3.7+. Don't even bother before. Not that it's not possible, but I've done it, and it's not worth the trouble.
Then, all tutorials should mention wait() or gather(), which are the most important functions of the whole framework. It kills me to never see those explained.
With just that knowledge, you can script happily at least as easily as with the pools I just had show case.
Now, I really hope that we are going to get trio's nurseries imported in the stdlib. yury selivanov is working on it from uvloop, so I got good hopes.
I did a proof of concept as an asyncio lib and it works decently, but having a standard would be much, much better.