[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: how to make a callback based socket interface?
- From: Petite Abeille <petite.abeille@...>
- Date: Fri, 30 Sep 2011 12:56:51 +0200
On Sep 30, 2011, at 12:35 PM, steve donovan wrote:
> The key thing to understand is that the listening socket is not
> blocking, it's just on a short timeout. Copas uses that timeout to
> schedule the coroutines and resume listening. So it is not 'true'
> multithreading but works well enough.
Right. Works well enough as far as coroutine goes. But is it worth the bother? After all, most applications spend time *doing* something with their IO. Not necessarily waiting for it. Except in the most trivial of cases. In other words, a typical application will spend most of its time processing the input and generating the output (i.e. application logic, the bread and butter of the app). And during that time your coroutine is, well, busy doing some real work. So no concurrency there, unless you litter your application code with zillions of yields to pass control back to the dispatcher to avoid, hmmm, coroutine starvation.
In any case, while I do like coroutine to help with logic flow, I'm skeptical about its positive performance impact.
As always, YMMV.