##// END OF EJS Templates
cleanup: directly use concurrent.futures instead of via pycompat...
Augie Fackler -
r49690:a0da5075 default
parent child Browse files
Show More
@@ -14,6 +14,7 b' import os'
14 14 import socket
15 15 import struct
16 16
17 from concurrent import futures
17 18 from .i18n import _
18 19 from .pycompat import getattr
19 20 from . import (
@@ -538,12 +539,12 b' class httppeer(wireprotov1peer.wirepeer)'
538 539 raise exception
539 540
540 541
541 class queuedcommandfuture(pycompat.futures.Future):
542 class queuedcommandfuture(futures.Future):
542 543 """Wraps result() on command futures to trigger submission on call."""
543 544
544 545 def result(self, timeout=None):
545 546 if self.done():
546 return pycompat.futures.Future.result(self, timeout)
547 return futures.Future.result(self, timeout)
547 548
548 549 self._peerexecutor.sendcommands()
549 550
@@ -16,6 +16,7 b' import sys'
16 16 import time
17 17 import weakref
18 18
19 from concurrent import futures
19 20 from .i18n import _
20 21 from .node import (
21 22 bin,
@@ -278,7 +279,7 b' class localcommandexecutor(object):'
278 279 # method on the peer and return a resolved future.
279 280 fn = getattr(self._peer, pycompat.sysstr(command))
280 281
281 f = pycompat.futures.Future()
282 f = futures.Future()
282 283
283 284 try:
284 285 result = fn(**pycompat.strkwargs(args))
@@ -35,8 +35,6 b' if not ispy3:'
35 35 import SocketServer as socketserver
36 36 import xmlrpclib
37 37
38 from .thirdparty.concurrent import futures
39
40 38 def future_set_exception_info(f, exc_info):
41 39 f.set_exception_info(*exc_info)
42 40
@@ -45,7 +43,6 b' if not ispy3:'
45 43
46 44 else:
47 45 import builtins
48 import concurrent.futures as futures
49 46 import http.cookiejar as cookielib
50 47 import http.client as httplib
51 48 import pickle
@@ -10,6 +10,7 b' from __future__ import absolute_import'
10 10 import sys
11 11 import weakref
12 12
13 from concurrent import futures
13 14 from .i18n import _
14 15 from .node import bin
15 16 from .pycompat import (
@@ -88,7 +89,7 b' def encodebatchcmds(req):'
88 89 return b';'.join(cmds)
89 90
90 91
91 class unsentfuture(pycompat.futures.Future):
92 class unsentfuture(futures.Future):
92 93 """A Future variation to represent an unsent command.
93 94
94 95 Because we buffer commands and don't submit them immediately, calling
@@ -99,7 +100,7 b' class unsentfuture(pycompat.futures.Futu'
99 100
100 101 def result(self, timeout=None):
101 102 if self.done():
102 return pycompat.futures.Future.result(self, timeout)
103 return futures.Future.result(self, timeout)
103 104
104 105 self._peerexecutor.sendcommands()
105 106
@@ -154,7 +155,7 b' class peerexecutor(object):'
154 155 # a batchable one and refuse to service it.
155 156
156 157 def addcall():
157 f = pycompat.futures.Future()
158 f = futures.Future()
158 159 self._futures.add(f)
159 160 self._calls.append((command, args, fn, f))
160 161 return f
@@ -194,7 +195,7 b' class peerexecutor(object):'
194 195 # cycle between us and futures.
195 196 for f in self._futures:
196 197 if isinstance(f, unsentfuture):
197 f.__class__ = pycompat.futures.Future
198 f.__class__ = futures.Future
198 199 f._peerexecutor = None
199 200
200 201 calls = self._calls
@@ -258,7 +259,7 b' class peerexecutor(object):'
258 259 # hard and it is easy to encounter race conditions, deadlocks, etc.
259 260 # concurrent.futures already solves these problems and its thread pool
260 261 # executor has minimal overhead. So we use it.
261 self._responseexecutor = pycompat.futures.ThreadPoolExecutor(1)
262 self._responseexecutor = futures.ThreadPoolExecutor(1)
262 263 self._responsef = self._responseexecutor.submit(
263 264 self._readbatchresponse, states, wireresults
264 265 )
General Comments 0
You need to be logged in to leave comments. Login now