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.
--- 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)