Thread Previous • Date Previous • Date Next • Thread Next |
On 03/02/2012 01:35 PM, Joshua Harlow wrote:
Does anyone else feel that the following seems really “dirty”, or is it just me. “adding a few sleep(0) calls in various places in the Nova codebase (as was recently added in the _sync_power_states() periodic task) is an easy and simple win with pretty much no ill side-effects. :)” Dirty in that it feels like there is something wrong from a design point of view. Sprinkling “sleep(0)” seems like its a band-aid on a larger problem imho. But that’s just my gut feeling.
It's not really all that dirty, IMHO. You just have to think of greenlet.sleep(0) as manually yielding control back to eventlet...
Like Phil said, in the absence of a non-userspace threading model and thread scheduler, there's not a whole lot else one can do other than be mindful of what functions/methods may run for long periods of time and/or block I/O and call sleep(0) in those scenarios where it makes sense to yield a timeslice back to other processes.
While it's true that eventlet (and to an extent Twisted) mask some of the complexities involved in non-blocking I/O in a threaded(-like) application programming model, I don't think there will be an eventlet-that-knows-what-methods-should-yield-and-which-should-be-prioritized library any time soon.
-jay
Thread Previous • Date Previous • Date Next • Thread Next |