##// 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 import sys
38 import sys
39 import time
39 import time
40 import threading
40
41
41 from mercurial.i18n import _
42 from mercurial.i18n import _
42 testedwith = 'internal'
43 testedwith = 'internal'
@@ -90,6 +91,7 b' def fmtremaining(seconds):'
90 class progbar(object):
91 class progbar(object):
91 def __init__(self, ui):
92 def __init__(self, ui):
92 self.ui = ui
93 self.ui = ui
94 self._refreshlock = threading.Lock()
93 self.resetstate()
95 self.resetstate()
94
96
95 def resetstate(self):
97 def resetstate(self):
@@ -241,6 +243,7 b' class progbar(object):'
241
243
242 def progress(self, topic, pos, item='', unit='', total=None):
244 def progress(self, topic, pos, item='', unit='', total=None):
243 now = time.time()
245 now = time.time()
246 self._refreshlock.acquire()
244 try:
247 try:
245 if pos is None:
248 if pos is None:
246 self.starttimes.pop(topic, None)
249 self.starttimes.pop(topic, None)
@@ -273,7 +276,7 b' class progbar(object):'
273 self.lastprint = now
276 self.lastprint = now
274 self.show(now, topic, *self.topicstates[topic])
277 self.show(now, topic, *self.topicstates[topic])
275 finally:
278 finally:
276 pass
279 self._refreshlock.release()
277
280
278 _singleton = None
281 _singleton = None
279
282
General Comments 0
You need to be logged in to leave comments. Login now