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