Handle exceptions gracefully when trying to read the command's output.

Signed-off-by: Michael Hanselmann <[email protected]>
---
 tools/ganeti-listrunner |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/ganeti-listrunner b/tools/ganeti-listrunner
index b9371a9..6fe176d 100755
--- a/tools/ganeti-listrunner
+++ b/tools/ganeti-listrunner
@@ -323,7 +323,14 @@ def RunRemoteCommand(connection, command, logfile):
    ### Read when data is available
   output = ""
   while select.select([session], [], []):
-    data = session.recv(1024)
+    try:
+      data = session.recv(1024)
+    except socket.timeout, err:
+      data = None
+      WriteLog("FAILED: socket.timeout %s" % err, logfile)
+    except socket.error, err:
+      data = None
+      WriteLog("FAILED: socket.error %s" % err, logfile)
     if not data:
       break
     output += data
-- 
1.7.6

Reply via email to