Mercurial > hg > mercurial-source
changeset 23920:5502bd79d052
progress: add a lock to prepare for introducing a thread
author | Solomon Matthews <smat@fb.com> |
---|---|
date | Sat, 17 Jan 2015 13:13:16 -0800 |
parents | 63c7783a5928 |
children | 0760f023a34b |
files | hgext/progress.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/progress.py +++ b/hgext/progress.py @@ -37,6 +37,7 @@ import sys import time +import threading from mercurial.i18n import _ testedwith = 'internal' @@ -90,6 +91,7 @@ class progbar(object): def __init__(self, ui): self.ui = ui + self._refreshlock = threading.Lock() self.resetstate() def resetstate(self): @@ -241,6 +243,7 @@ def progress(self, topic, pos, item='', unit='', total=None): now = time.time() + self._refreshlock.acquire() try: if pos is None: self.starttimes.pop(topic, None) @@ -273,7 +276,7 @@ self.lastprint = now self.show(now, topic, *self.topicstates[topic]) finally: - pass + self._refreshlock.release() _singleton = None