mercurial/scmutil.py
changeset 28819 826d457df138
parent 28197 2ada62388bb1
child 29017 07be86828e79
equal deleted inserted replaced
28818:6041fb8f2da8 28819:826d457df138
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import Queue
       
    11 import contextlib
    10 import contextlib
    12 import errno
    11 import errno
    13 import glob
    12 import glob
    14 import os
    13 import os
    15 import re
    14 import re
  1318         threadcount = ui.configint('worker', 'backgroundclosethreadcount', 4)
  1317         threadcount = ui.configint('worker', 'backgroundclosethreadcount', 4)
  1319 
  1318 
  1320         ui.debug('starting %d threads for background file closing\n' %
  1319         ui.debug('starting %d threads for background file closing\n' %
  1321                  threadcount)
  1320                  threadcount)
  1322 
  1321 
  1323         self._queue = Queue.Queue(maxsize=maxqueue)
  1322         self._queue = util.queue(maxsize=maxqueue)
  1324         self._running = True
  1323         self._running = True
  1325 
  1324 
  1326         for i in range(threadcount):
  1325         for i in range(threadcount):
  1327             t = threading.Thread(target=self._worker, name='backgroundcloser')
  1326             t = threading.Thread(target=self._worker, name='backgroundcloser')
  1328             self._threads.append(t)
  1327             self._threads.append(t)
  1350                 try:
  1349                 try:
  1351                     fh.close()
  1350                     fh.close()
  1352                 except Exception as e:
  1351                 except Exception as e:
  1353                     # Stash so can re-raise from main thread later.
  1352                     # Stash so can re-raise from main thread later.
  1354                     self._threadexception = e
  1353                     self._threadexception = e
  1355             except Queue.Empty:
  1354             except util.empty:
  1356                 if not self._running:
  1355                 if not self._running:
  1357                     break
  1356                     break
  1358 
  1357 
  1359     def close(self, fh):
  1358     def close(self, fh):
  1360         """Schedule a file for closing."""
  1359         """Schedule a file for closing."""