Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotov1peer.py @ 46711:aa2e38147e8b
wireprotov1peer: don't raise internal errors in some cases
Specifically, when the peer is closed in the middle of a batch of rpcs.
Differential Revision: https://phab.mercurial-scm.org/D10074
author | Valentin Gatien-Baron <vgatien-baron@janestreet.com> |
---|---|
date | Thu, 25 Feb 2021 10:08:33 -0500 |
parents | 05dd091dfa6a |
children | d4ba4d51f85f |
line wrap: on
line diff
--- a/mercurial/wireprotov1peer.py Thu Feb 25 10:00:08 2021 -0500 +++ b/mercurial/wireprotov1peer.py Thu Feb 25 10:08:33 2021 -0500 @@ -310,7 +310,7 @@ if not f.done(): f.set_exception( error.ResponseError( - _(b'unfulfilled batch command response') + _(b'unfulfilled batch command response'), None ) ) @@ -322,16 +322,27 @@ for command, f, batchable, fremote in states: # Grab raw result off the wire and teach the internal future # about it. - remoteresult = next(wireresults) - fremote.set(remoteresult) + try: + remoteresult = next(wireresults) + except StopIteration: + # This can happen in particular because next(batchable) + # in the previous iteration can call peer._abort, which + # may close the peer. + f.set_exception( + error.ResponseError( + _(b'unfulfilled batch command response'), None + ) + ) + else: + fremote.set(remoteresult) - # And ask the coroutine to decode that value. - try: - result = next(batchable) - except Exception: - pycompat.future_set_exception_info(f, sys.exc_info()[1:]) - else: - f.set_result(result) + # And ask the coroutine to decode that value. + try: + result = next(batchable) + except Exception: + pycompat.future_set_exception_info(f, sys.exc_info()[1:]) + else: + f.set_result(result) @interfaceutil.implementer(