5 ms·
Or just use curio or trio and have an infinitely better time with async in python :)
by theelous3 6y ago
Or just use curio or trio and have an infinitely better time with async in python :)
- nurettin 6y agoI see no reason to use curio or anything instead of standard asyncio. Works really well for me. Queue tasks, they finish at their leisure, create futures and locks to control flow, all really easy and bugless code. And you get async redis, async http, a lot of asyncio functions for free. So no, I will not change it for some "really well architected library that takes away all your pains" because there aren't any.
- gjvc 6y agoWhat do you use for HTTP message handling?
- nurettin 6y agoWell, there is no request router in asyncio-http, so I have to use async views in django or if I need something lightweight I go with Quart. But if I was given the proper time, I'd probably invent my own routing on top of asyncio-http using google's re2 to parse the REST requests like I did here some years ago. https://github.com/nurettin/pwned/blob/master/server/server.hpp#L84 https://github.com/nurettin/pwned/blob/master/server/server....
- takeda 6y agoBy asyncio http do you mean aiohttp? Besides the standard way, you can also register routes similarly to DJango and Flask: https://docs.aiohttp.org/en/stable/web_quickstart.html#alternative-ways-for-registering-routes https://docs.aiohttp.org/en/stable/web_quickstart.html#alter...
- nurettin 6y agooh I haven't noticed it had a router, thanks
- downerending 6y agoThe reason is that curio is well-designed and has a reasonably compact story for how things work. It fits in my head. And the "cool new things I can do with it" to "how hard is it to learn" ratio is pretty high. Asyncio on the other hand, feels like being beaten with a stick. It's so complicated that normal humans are never really going to understand it all. On top of that, it's been morphing all through the 3.0 series, so there isn't even one spec to learn--it's more like a set.
- nurettin 6y agoWhat do you mean compact story? How do humans not understand asyncio? I think I pretty much do, and I use it in production, with several interconnected services. How has curio been morphing? How is morphing actually a good thing? Isn't it bad that an api is unstable? Overall I understood little to nothing from your comment.
- downerending 6y agoThe curio module has not been morphing, which is part of what I like about it. The async module has been changing, which like you, I dislike. The "right" way to do asyncio would have been to properly mull the design into its final form and then introduce it into Python3. Instead, it appears to have been dribbled in piecemeal over several releases. Beyond that, it's just plain complex and confusing. I haven't bothered to use it for anything so far. I'm hoping someone will show up with a machete and cut it down into something usable. Right now, it resembles C++.
- nurettin 6y agoYeah I haven't actually used it until 3.6.9 where it turned into its current final form. What is confusing about asyncio and how does curio solve that problem?
- theelous3 6y ago"I can use this wrench to drive a nail, what would I want a hammer for?" is basically how this reads. I'm not saying software can't be written with asyncio, I'm just saying curio and trio are better.
- gjvc 6y agocurio is by David Beazley, [1] which should be reason enough to investigate it. [1] once memorably dubbed "the people's champion" in the introduction to one of his PyCon speeches.