Change in vdsm[master]: vdsm: Add additional exception handling within vmChannels.py

lyarwood at redhat.com lyarwood at redhat.com
Fri Mar 15 18:23:52 UTC 2013


Lee Yarwood has uploaded a new change for review.

Change subject: vdsm: Add additional exception handling within vmChannels.py
......................................................................

vdsm: Add additional exception handling within vmChannels.py

At present any exception thrown by _epoll.poll(1) is not caught. This patch adds
additional exception handling to catch and log any exceptions thrown by the
thread.

Change-Id: Ie733ca7ccd2689f6041ee18bbe335f355a89ac55
Signed-off-by: Lee Yarwood <lyarwood at redhat.com>
---
M vdsm/vmChannels.py
1 file changed, 21 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/13093/1

diff --git a/vdsm/vmChannels.py b/vdsm/vmChannels.py
index 1d20f1d..024ba4f 100644
--- a/vdsm/vmChannels.py
+++ b/vdsm/vmChannels.py
@@ -21,6 +21,7 @@
 import threading
 import time
 import select
+import errno
 
 
 class Listener(threading.Thread):
@@ -114,21 +115,33 @@
 
     def _wait_for_events(self):
         """ Wait for an epoll event and handle channels' timeout. """
-        events = self._epoll.poll(1)
-        for (fileno, event) in events:
-            self._handle_event(fileno, event)
+        try:
+            events = self._epoll.poll(1)
+        except IOError as err:
+            # We don't want to log a quite common error
+            if err.errno is not errno.EINTR:
+                self.log.exception("IOError on epoll.poll(1)")
+        except:
+            self.log.exception("Exception on epoll.poll(1)")
         else:
-            self._update_channels()
-            if (self._timeout is not None) and (self._timeout > 0):
-                self._handle_timeouts()
-            self._handle_unconnected()
+            for (fileno, event) in events:
+                self._handle_event(fileno, event)
+            else:
+                self._update_channels()
+                if (self._timeout is not None) and (self._timeout > 0):
+                    self._handle_timeouts()
+                self._handle_unconnected()
 
     def run(self):
         """ The listener thread's function. """
         self.log.info("Starting VM channels listener thread.")
         self._quit = False
         while not self._quit:
-            self._wait_for_events()
+            try:
+                self._wait_for_events()
+            except:
+                self.log.exception("Unhandled exception caught in vm channels "
+                                   "listener thread")
 
     def stop(self):
         """" Stop the listener execution. """


--
To view, visit http://gerrit.ovirt.org/13093
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie733ca7ccd2689f6041ee18bbe335f355a89ac55
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lee Yarwood <lyarwood at redhat.com>


More information about the vdsm-patches mailing list