3 ms·
> Do people use coroutines? Yes, but not in production code. Are you serious? Well, first, surely in all this talk of cooperative threading, you also include
by ploxiln 10y ago
> Do people use coroutines? Yes, but not in production code.
Are you serious?
Well, first, surely in all this talk of cooperative threading, you also include callback-oriented event-based programming. This is HUGE.
Have you heard of nginx?
But also, I've personally worked on very high volume api servicing and analytics, largely written in python using tornado (which is very similar to twisted) for a very popular web service: Bitly. There were also a couple significant components written in c using libevent, another similar event-ed i/o mini-framework, involving lots of callbacks.
It can be done right and be readable and debug-able, and it can be super efficient, more efficient than spawning threads for hundreds or thousands of parallel i/o tasks (or managing a thread pool or forking processes or whatever).
It's not for everything but it's definitely in serious production environments. The more serious, the more likely to use event-ed i/o.
- mdomans 10y agoCooperative concurrency and event-based programming are different concepts. You need events for the coroutine since scheduler needs to base trampolining of something. Alas, you can do event based programming without coroutines. Yes, I used libevent and libev and I do love nginx :)