Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotov1peer.py @ 48926:a0da5075bca3
cleanup: directly use concurrent.futures instead of via pycompat
Python 2 is gone.
Differential Revision: https://phab.mercurial-scm.org/D12279
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 02 Mar 2022 10:24:49 -0500 |
parents | c424ff4807e6 |
children | 6000f5b25c9b |
line wrap: on
line diff
--- a/mercurial/wireprotov1peer.py Wed Mar 02 10:23:53 2022 -0500 +++ b/mercurial/wireprotov1peer.py Wed Mar 02 10:24:49 2022 -0500 @@ -10,6 +10,7 @@ import sys import weakref +from concurrent import futures from .i18n import _ from .node import bin from .pycompat import ( @@ -88,7 +89,7 @@ return b';'.join(cmds) -class unsentfuture(pycompat.futures.Future): +class unsentfuture(futures.Future): """A Future variation to represent an unsent command. Because we buffer commands and don't submit them immediately, calling @@ -99,7 +100,7 @@ def result(self, timeout=None): if self.done(): - return pycompat.futures.Future.result(self, timeout) + return futures.Future.result(self, timeout) self._peerexecutor.sendcommands() @@ -154,7 +155,7 @@ # a batchable one and refuse to service it. def addcall(): - f = pycompat.futures.Future() + f = futures.Future() self._futures.add(f) self._calls.append((command, args, fn, f)) return f @@ -194,7 +195,7 @@ # cycle between us and futures. for f in self._futures: if isinstance(f, unsentfuture): - f.__class__ = pycompat.futures.Future + f.__class__ = futures.Future f._peerexecutor = None calls = self._calls @@ -258,7 +259,7 @@ # hard and it is easy to encounter race conditions, deadlocks, etc. # concurrent.futures already solves these problems and its thread pool # executor has minimal overhead. So we use it. - self._responseexecutor = pycompat.futures.ThreadPoolExecutor(1) + self._responseexecutor = futures.ThreadPoolExecutor(1) self._responsef = self._responseexecutor.submit( self._readbatchresponse, states, wireresults )