cleanup: directly use concurrent.futures instead of via pycompat
authorAugie Fackler <augie@google.com>
Wed, 02 Mar 2022 10:24:49 -0500
changeset 48926 a0da5075bca3
parent 48925 029b76d645dc
child 48927 e020dbbc41e5
cleanup: directly use concurrent.futures instead of via pycompat Python 2 is gone. Differential Revision: https://phab.mercurial-scm.org/D12279
mercurial/httppeer.py
mercurial/localrepo.py
mercurial/pycompat.py
mercurial/wireprotov1peer.py
--- a/mercurial/httppeer.py	Wed Mar 02 10:23:53 2022 -0500
+++ b/mercurial/httppeer.py	Wed Mar 02 10:24:49 2022 -0500
@@ -14,6 +14,7 @@
 import socket
 import struct
 
+from concurrent import futures
 from .i18n import _
 from .pycompat import getattr
 from . import (
@@ -538,12 +539,12 @@
         raise exception
 
 
-class queuedcommandfuture(pycompat.futures.Future):
+class queuedcommandfuture(futures.Future):
     """Wraps result() on command futures to trigger submission on call."""
 
     def result(self, timeout=None):
         if self.done():
-            return pycompat.futures.Future.result(self, timeout)
+            return futures.Future.result(self, timeout)
 
         self._peerexecutor.sendcommands()
 
--- a/mercurial/localrepo.py	Wed Mar 02 10:23:53 2022 -0500
+++ b/mercurial/localrepo.py	Wed Mar 02 10:24:49 2022 -0500
@@ -16,6 +16,7 @@
 import time
 import weakref
 
+from concurrent import futures
 from .i18n import _
 from .node import (
     bin,
@@ -278,7 +279,7 @@
         # method on the peer and return a resolved future.
         fn = getattr(self._peer, pycompat.sysstr(command))
 
-        f = pycompat.futures.Future()
+        f = futures.Future()
 
         try:
             result = fn(**pycompat.strkwargs(args))
--- a/mercurial/pycompat.py	Wed Mar 02 10:23:53 2022 -0500
+++ b/mercurial/pycompat.py	Wed Mar 02 10:24:49 2022 -0500
@@ -35,8 +35,6 @@
     import SocketServer as socketserver
     import xmlrpclib
 
-    from .thirdparty.concurrent import futures
-
     def future_set_exception_info(f, exc_info):
         f.set_exception_info(*exc_info)
 
@@ -45,7 +43,6 @@
 
 else:
     import builtins
-    import concurrent.futures as futures
     import http.cookiejar as cookielib
     import http.client as httplib
     import pickle
--- 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
         )