changeset 8788:5d8021ac0e19

inotify: raise QueryFailed when the server crash When the server crashes, it does not write back on the socket. The message which is then read from the socket is '', which raises a TypeError. Catching TypeError to raise QueryFailed instead.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Sat, 13 Jun 2009 17:39:01 +0200
parents 9aca76502280
children e0ed17984a48
files hgext/inotify/client.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/inotify/client.py	Wed May 27 00:29:11 2009 +0900
+++ b/hgext/inotify/client.py	Sat Jun 13 17:39:01 2009 +0200
@@ -91,7 +91,13 @@
         Raises QueryFailed on error
         """
         cs = common.recvcs(self.sock)
-        version = ord(cs.read(1))
+        try:
+            version = ord(cs.read(1))
+        except TypeError:
+            # empty answer, assume the server crashed
+            self.ui.warn(_('received empty answer from inotify server'))
+            raise QueryFailed('server crashed')
+
         if version != common.version:
             self.ui.warn(_('(inotify: received response from incompatible '
                       'server version %d)\n') % version)