diff hglib/client.py @ 189:8054e925d9c7

client: kill the server on unrecoverable communication errors (issue5516) Once an unrecoverable communication error occurs between the client and server, it's no longer safe to send further commands to the same server. On Windows, attempting to do so is known to cause lockups and memory leaks. Close the client and kill the server when an such an error occurs. This way, any further commands will fail gracefully with ValueError until the client is reopened.
author Gábor Stefanik <gabor.stefanik@nng.com>
date Mon, 21 Aug 2017 17:02:14 +0200
parents 5609a21fe39a
children f38bc0569671
line wrap: on
line diff
--- a/hglib/client.py	Tue Sep 12 13:16:36 2017 -0400
+++ b/hglib/client.py	Mon Aug 21 17:02:14 2017 +0200
@@ -139,6 +139,7 @@
     def _readchannel(self):
         data = self.server.stdout.read(hgclient.outputfmtsize)
         if not data:
+            self.close()
             raise error.ServerError()
         channel, length = struct.unpack(hgclient.outputfmt, data)
         if channel in b('IL'):
@@ -190,6 +191,7 @@
                 return struct.unpack(hgclient.retfmt, data)[0]
             # a channel that we don't know and can't ignore
             elif channel.isupper():
+                self.close()
                 raise error.ResponseError(
                     "unexpected data on required channel '%s'" % channel)
             # optional channel