Show More
@@ -340,7 +340,8 b' pypats = [' | |||
|
340 | 340 | (r'\butil\.Abort\b', "directly use error.Abort"), |
|
341 | 341 | (r'^@(\w*\.)?cachefunc', "module-level @cachefunc is risky, please avoid"), |
|
342 | 342 | (r'^import atexit', "don't use atexit, use ui.atexit"), |
|
343 |
(r'^import Queue', "don't use Queue, use |
|
|
343 | (r'^import Queue', "don't use Queue, use pycompat.queue.Queue + " | |
|
344 | "pycompat.queue.Empty"), | |
|
344 | 345 | (r'^import cStringIO', "don't use cStringIO.StringIO, use util.stringio"), |
|
345 | 346 | (r'^import urllib', "don't use urllib, use util.urlreq/util.urlerr"), |
|
346 | 347 | (r'^import SocketServer', "don't use SockerServer, use util.socketserver"), |
@@ -71,6 +71,16 b' except (ImportError, AttributeError):' | |||
|
71 | 71 | import inspect |
|
72 | 72 | getargspec = inspect.getargspec |
|
73 | 73 | |
|
74 | try: | |
|
75 | # 4.7+ | |
|
76 | queue = pycompat.queue.Queue | |
|
77 | except (AttributeError, ImportError): | |
|
78 | # <4.7. | |
|
79 | try: | |
|
80 | queue = pycompat.queue | |
|
81 | except (AttributeError, ImportError): | |
|
82 | queue = util.queue | |
|
83 | ||
|
74 | 84 | # for "historical portability": |
|
75 | 85 | # define util.safehasattr forcibly, because util.safehasattr has been |
|
76 | 86 | # available since 1.9.3 (or 94b200a11cf7) |
@@ -1029,7 +1039,7 b' def perfbdiff(ui, repo, file_, rev=None,' | |||
|
1029 | 1039 | else: |
|
1030 | 1040 | mdiff.textdiff(*pair) |
|
1031 | 1041 | else: |
|
1032 |
q = |
|
|
1042 | q = queue() | |
|
1033 | 1043 | for i in xrange(threads): |
|
1034 | 1044 | q.put(None) |
|
1035 | 1045 | ready = threading.Condition() |
@@ -23,7 +23,7 b' if not ispy3:' | |||
|
23 | 23 | import cookielib |
|
24 | 24 | import cPickle as pickle |
|
25 | 25 | import httplib |
|
26 |
import Queue as |
|
|
26 | import Queue as queue | |
|
27 | 27 | import SocketServer as socketserver |
|
28 | 28 | import xmlrpclib |
|
29 | 29 | |
@@ -36,16 +36,13 b' else:' | |||
|
36 | 36 | import http.cookiejar as cookielib |
|
37 | 37 | import http.client as httplib |
|
38 | 38 | import pickle |
|
39 |
import queue as |
|
|
39 | import queue as queue | |
|
40 | 40 | import socketserver |
|
41 | 41 | import xmlrpc.client as xmlrpclib |
|
42 | 42 | |
|
43 | 43 | def future_set_exception_info(f, exc_info): |
|
44 | 44 | f.set_exception(exc_info[0]) |
|
45 | 45 | |
|
46 | empty = _queue.Empty | |
|
47 | queue = _queue.Queue | |
|
48 | ||
|
49 | 46 | def identity(a): |
|
50 | 47 | return a |
|
51 | 48 |
@@ -60,10 +60,8 b' b85decode = base85.b85decode' | |||
|
60 | 60 | b85encode = base85.b85encode |
|
61 | 61 | |
|
62 | 62 | cookielib = pycompat.cookielib |
|
63 | empty = pycompat.empty | |
|
64 | 63 | httplib = pycompat.httplib |
|
65 | 64 | pickle = pycompat.pickle |
|
66 | queue = pycompat.queue | |
|
67 | 65 | safehasattr = pycompat.safehasattr |
|
68 | 66 | socketserver = pycompat.socketserver |
|
69 | 67 | bytesio = pycompat.bytesio |
@@ -568,7 +568,7 b' class backgroundfilecloser(object):' | |||
|
568 | 568 | ui.debug('starting %d threads for background file closing\n' % |
|
569 | 569 | threadcount) |
|
570 | 570 | |
|
571 |
self._queue = |
|
|
571 | self._queue = pycompat.queue.Queue(maxsize=maxqueue) | |
|
572 | 572 | self._running = True |
|
573 | 573 | |
|
574 | 574 | for i in range(threadcount): |
@@ -600,7 +600,7 b' class backgroundfilecloser(object):' | |||
|
600 | 600 | except Exception as e: |
|
601 | 601 | # Stash so can re-raise from main thread later. |
|
602 | 602 | self._threadexception = e |
|
603 |
except |
|
|
603 | except pycompat.queue.Empty: | |
|
604 | 604 | if not self._running: |
|
605 | 605 | break |
|
606 | 606 |
@@ -235,7 +235,7 b' def _windowsworker(ui, func, staticargs,' | |||
|
235 | 235 | # iteration. |
|
236 | 236 | if self._interrupted: |
|
237 | 237 | return |
|
238 |
except |
|
|
238 | except pycompat.queue.Empty: | |
|
239 | 239 | break |
|
240 | 240 | except Exception as e: |
|
241 | 241 | # store the exception such that the main thread can resurface |
@@ -262,8 +262,8 b' def _windowsworker(ui, func, staticargs,' | |||
|
262 | 262 | return |
|
263 | 263 | |
|
264 | 264 | workers = _numworkers(ui) |
|
265 |
resultqueue = |
|
|
266 |
taskqueue = |
|
|
265 | resultqueue = pycompat.queue.Queue() | |
|
266 | taskqueue = pycompat.queue.Queue() | |
|
267 | 267 | # partition work to more pieces than workers to minimize the chance |
|
268 | 268 | # of uneven distribution of large tasks between the workers |
|
269 | 269 | for pargs in partition(args, workers * 20): |
General Comments 0
You need to be logged in to leave comments.
Login now