Changeset View
Changeset View
Standalone View
Standalone View
mercurial/wireprotov1peer.py
Show First 20 Lines • Show All 304 Lines • ▼ Show 20 Line(s) | def close(self): | ||||
self._responseexecutor = None | self._responseexecutor = None | ||||
# If any of our futures are still in progress, mark them as | # If any of our futures are still in progress, mark them as | ||||
# errored. Otherwise a result() could wait indefinitely. | # errored. Otherwise a result() could wait indefinitely. | ||||
for f in self._futures: | for f in self._futures: | ||||
if not f.done(): | if not f.done(): | ||||
f.set_exception( | f.set_exception( | ||||
error.ResponseError( | error.ResponseError( | ||||
_(b'unfulfilled batch command response') | _(b'unfulfilled batch command response'), None | ||||
) | ) | ||||
) | ) | ||||
self._futures = None | self._futures = None | ||||
def _readbatchresponse(self, states, wireresults): | def _readbatchresponse(self, states, wireresults): | ||||
# Executes in a thread to read data off the wire. | # Executes in a thread to read data off the wire. | ||||
for command, f, batchable, fremote in states: | for command, f, batchable, fremote in states: | ||||
# Grab raw result off the wire and teach the internal future | # Grab raw result off the wire and teach the internal future | ||||
# about it. | # about it. | ||||
try: | |||||
remoteresult = next(wireresults) | 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) | fremote.set(remoteresult) | ||||
# And ask the coroutine to decode that value. | # And ask the coroutine to decode that value. | ||||
try: | try: | ||||
result = next(batchable) | result = next(batchable) | ||||
except Exception: | except Exception: | ||||
pycompat.future_set_exception_info(f, sys.exc_info()[1:]) | pycompat.future_set_exception_info(f, sys.exc_info()[1:]) | ||||
else: | else: | ||||
f.set_result(result) | f.set_result(result) | ||||
@interfaceutil.implementer( | @interfaceutil.implementer( | ||||
repository.ipeercommands, repository.ipeerlegacycommands | repository.ipeercommands, repository.ipeerlegacycommands | ||||
) | ) | ||||
class wirepeer(repository.peer): | class wirepeer(repository.peer): | ||||
"""Client-side interface for communicating with a peer repository. | """Client-side interface for communicating with a peer repository. | ||||
▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines |