Gevent in a nogil Python world
I've looked for discussion areas for gevent and haven't found more than some really good and interesting traffic here in the issue tracker. To the point:
Armin Ronacher has an interesting post out favoring threads over async/await. https://lucumr.pocoo.org/2024/11/18/threads-beat-async-await/
While I agree with his conclusion, I'm not as keen on his reasoning. I think it's really simple – when you have a single-threaded environment, async/await based on continuations and Promises/Futures is a wonderful way to keep callback hell to a minimum when implementing concurrency. In a multi-threaded environment, async/await pollutes with function coloring and just generally gets in the way. Regular threads are a much better tool to use (green or otherwise).
There was also some interesting traffic on the Python Aysnc-SIG list:
https://discuss.python.org/t/asyncio-in-a-nogil-world/30694/3
If indeed sentiment is drifting away from async/await as a preferred concurrency mechanism for Python (personally, I think asyncio is doomed to failure due to the use of generators instead of continuations + Promises for the plumbing), and now that nogil is upon us, I think this represents an interesting opportunity for Gevent.
If:
- Gevent core is made thread-safe (and nogil safe).
- Gevent transitions to an M:N model of M greenlets to a pool of N threads with each one using stack swapping.
Then it seems that Gevent could become the defacto greenthread standard for Python (which personally, I believe it is destined for regardless of the current circumstances).
Anyway, just my $0.02 - hoping to spark some discussion about the possibilities.
As always, thank you for the tremendous work on such an excellent piece of software!
Source: gevent/gevent