inotify: raise QueryFailed when the server crash
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sat, 13 Jun 2009 17:39:01 +0200
changeset 8788 5d8021ac0e19
parent 8787 9aca76502280
child 8789 e0ed17984a48
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.
hgext/inotify/client.py
--- 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)