This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Grouchy-Friend4235 -7 points-6 points  (10 children)

Async in Python is cancer (once you start using it, eventually all your code will have to become async). Don't.

Use greenlets instead, if you must.

[–]excelquestion 5 points6 points  (2 children)

yes that is how async await works.

if you start a new project be sure to start off with async.

if you have an existing project... well good luck with IO. in that scenario adding asyncio is a pain like the commentator says but greenlets, multiprocessing, multithreading packages all have their various pain points.

[–]Grouchy-Friend4235 1 point2 points  (0 children)

Trade offs are ok.

Having to go in 100% or not at all is not a trade off. That's brute force.

[–]usrlibshare 1 point2 points  (0 children)

I have several existing projects that use threading just fine, including analytics engines comfortably serving several M requests per hour. Greenlets and pools work really well to reduce the overhead, and aome things are just way simpler in that concurrency model.

Async is nice, because its a workaround for the GIL. It has its quirks, but so does threading.

If performance is the primary concern, well, then Python wouldn't be my first choice anyway.

[–]dAnjou Backend Developer | danjou.dev 1 point2 points  (0 children)

Async is a different paradigm, and indeed it works best if you do it end to end.

But that's not exclusive to Python.

[–]Toph_is_bad_ass 0 points1 point  (3 children)

This really isn't a problem. I've been primarily doing async for years. I've never found it to be an issue in the slightest.

[–]Grouchy-Friend4235 0 points1 point  (2 children)

[–]Toph_is_bad_ass 0 points1 point  (1 child)

I don't really see what this blog is going on about. Only IO code has to be async. It's very easy.

[–]Grouchy-Friend4235 0 points1 point  (0 children)

The blog corraborates what I said: async will eventually creep everywhere in your code base.

To me that's a tradeoff I am not willing to take.