# HG changeset patch # User Gábor Stefanik # Date 1503327734 -7200 # Node ID 8054e925d9c764cfbf26aeba64b39de4e72aa21a # Parent 5609a21fe39ace1f45e1fbd7ebb8e6ec6d4b03d6 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. diff -r 5609a21fe39a -r 8054e925d9c7 hglib/client.py --- 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