[libvirt] [PATCH] add handling EINTR to test example of event loop
Royce Lv
lvroyce0210 at gmail.com
Mon Jun 18 07:20:52 UTC 2012
some system calls 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 at 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
# Dispatch any file handle events that
occurred
for (fd, revents) in
events:
--
1.7.7.6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120618/28c37cb6/attachment-0001.htm>
More information about the libvir-list
mailing list