Very simple async http requests
Learning Node, the one thing that's interesting is the ability to make lots of requests asynchronously. This would be useful if:
- You depending on many microservices or API's
- You want to download all the files in a blogpost, like Django Draftin does.
Can Python do this?
It does have new async features. Some inspiration and sample code:
What works well
Making very small async tasks and pulling them into a synchronous function. Kept simple, this could give us 95% of the benefits of async with the minimum confusion.
What barely works
Asyncio's docs are overwhelming. The fact that this also confuses Armin Ronacher suggests its not just my tiny imposter brain that finds it unapproachable.
aiohttp helps, but seems to leave out the simplest use case: the equivelant of:
try: resp = request.get("https://myurl.com") except Exception: msg = "Help! Something went horribly wrong!"
I hacked around it. It's not great.
What doesn't work at all
If you're running Flask in debug mode, as one does, you get a mysterious error:
RuntimeError: There is no current event loop in thread 'Thread-1'.
I can't find any useful insight into this.