##// END OF EJS Templates
progress: add a lock to prepare for introducing a thread
Solomon Matthews -
r23908:5502bd79 default
parent child Browse files
Show More
@@ -37,6 +37,7 b' characters.'
37 37
38 38 import sys
39 39 import time
40 import threading
40 41
41 42 from mercurial.i18n import _
42 43 testedwith = 'internal'
@@ -90,6 +91,7 b' def fmtremaining(seconds):'
90 91 class progbar(object):
91 92 def __init__(self, ui):
92 93 self.ui = ui
94 self._refreshlock = threading.Lock()
93 95 self.resetstate()
94 96
95 97 def resetstate(self):
@@ -241,6 +243,7 b' class progbar(object):'
241 243
242 244 def progress(self, topic, pos, item='', unit='', total=None):
243 245 now = time.time()
246 self._refreshlock.acquire()
244 247 try:
245 248 if pos is None:
246 249 self.starttimes.pop(topic, None)
@@ -273,7 +276,7 b' class progbar(object):'
273 276 self.lastprint = now
274 277 self.show(now, topic, *self.topicstates[topic])
275 278 finally:
276 pass
279 self._refreshlock.release()
277 280
278 281 _singleton = None
279 282
General Comments 0
You need to be logged in to leave comments. Login now