EventLoop.iteration(): avoid busy waiting
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Dec 2012 01:35:49 +0000 (17:35 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Dec 2012 01:44:27 +0000 (17:44 -0800)
commita0f22daa7cf359aac776a45bbc60d22dcd947034
tree21344bff13b0e407c730d2ef34f996c7ef1d5881
parent684e0f9fa1ed5039dc51e7854bd9cb318a2eaafe
EventLoop.iteration(): avoid busy waiting

In order to avoid blocking forever when may_block is True (the
default), callers must be careful to ensure that at least one of the
following conditions is met:
1) An event source or timeout is registered which is guaranteed
to trigger at least on event (a call to an idle function
only counts as an event if it returns a False value which
causes it to be stop being called)
2) Another thread is guaranteed to call one of the thread-safe
methods which notify iteration to stop waiting (such as
idle_add or timeout_add).
These rules ensure that iteration is able to block until an event
arrives, without doing any busy waiting that would waste CPU time.

This will fix busy waiting which would be triggered by
PopenPipeBlockingIOTestCase when waiting for the thread from
PipeReaderBlockingIO to call idle_add.
pym/portage/util/_eventloop/EventLoop.py