Mercurial > hg
comparison mercurial/vfs.py @ 37844:8fb9985382be
pycompat: export queue module instead of symbols in module (API)
Previously, pycompat and util re-exported individual symbols from the
queue module. This had the side-effect of forcing the loading of the
queue module whenever pycompat/util was imported.
These symbols aren't used very often. So importing the module to
get a handle on the symbols is wasteful.
This commit changes pycompat so it no longer exports the individual
symbols in the queue module. Instead, we make the imported module
a "public" symbol. We drop the individual symbol aliases from the
util module. All consumers are updated to use pycompat.queue.* instead.
This change makes 300 invocations of `hg log -r. -T '{rev}\n'` a little
faster:
before: 18.44s
after: 17.87s
Differential Revision: https://phab.mercurial-scm.org/D3441
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 05 May 2018 18:35:16 -0700 |
parents | 2a7e777c9eed |
children | aac4be30e250 |
comparison
equal
deleted
inserted
replaced
37843:670eb4fa1b86 | 37844:8fb9985382be |
---|---|
566 threadcount = ui.configint('worker', 'backgroundclosethreadcount') | 566 threadcount = ui.configint('worker', 'backgroundclosethreadcount') |
567 | 567 |
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 = util.queue(maxsize=maxqueue) | 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): |
575 t = threading.Thread(target=self._worker, name='backgroundcloser') | 575 t = threading.Thread(target=self._worker, name='backgroundcloser') |
576 self._threads.append(t) | 576 self._threads.append(t) |
598 try: | 598 try: |
599 fh.close() | 599 fh.close() |
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 util.empty: | 603 except pycompat.queue.Empty: |
604 if not self._running: | 604 if not self._running: |
605 break | 605 break |
606 | 606 |
607 def close(self, fh): | 607 def close(self, fh): |
608 """Schedule a file for closing.""" | 608 """Schedule a file for closing.""" |