On Mon, Jun 18, 2012 at 10:17:53PM +0300, Dan Kenigsberg wrote:
On Mon, Jun 18, 2012 at 10:56:26AM +0100, Daniel P. Berrange wrote:
> On Mon, Jun 18, 2012 at 05:43:55PM +0800, lvroyce(a)linux.vnet.ibm.com wrote:
> > From: lvroyce <lvroyce(a)linux.vnet.ibm.com>
> >
> > some system call and signal will interrupt poll,
> > making event loop stops and fails to react events and keepalive message
> > from libvirt.
> > adding handling EINTR to poll to make it more robust
> >
> > Signed-off-by: lvroyce <lvroyce(a)linux.vnet.ibm.com>
> > ---
> > examples/domain-events/events-python/event-test.py | 8 +++++++-
> > 1 files changed, 7 insertions(+), 1 deletions(-)
> >
> > diff --git a/examples/domain-events/events-python/event-test.py
b/examples/domain-events/events-python/event-test.py
> > index 96dc268..b446c21 100644
> > --- a/examples/domain-events/events-python/event-test.py
> > +++ b/examples/domain-events/events-python/event-test.py
> > @@ -188,7 +188,13 @@ class virEventLoopPure:
> > sleep = (next - now) / 1000.0
> >
> > debug("Poll with a sleep of %d" % sleep)
> > - events = self.poll.poll(sleep)
> > + try:
> > + events = self.poll.poll(sleep)
> > + except select.error, e:
> > + self.runningPoll = False
> > + if not e.errno in (errno.EINTR, errno.EAGAIN):
> > + raise
> > + return
>
> It isn't possible for poll() to return EAGAIN according to the
> manpage.
>
> If you remove that errno, then the patch would be ok. Also the
> indentation in the except: block is too deep - line it up with
> the try: block
The same function has another possible exception-raiser: os.read() few
lines below, and probably others. How about putting
self.runningPoll = False
in a "finally" clause opened right after the first self.runningPoll
assignment?
Sounds like a reasonable idea.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|