progress: use context manager for lock
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 19 Jun 2018 22:06:28 -0700
changeset 38417 6bd9f18d31a8
parent 38416 35b50237908b
child 38418 b34d0a6ef936
progress: use context manager for lock Differential Revision: https://phab.mercurial-scm.org/D3820
mercurial/progress.py
--- a/mercurial/progress.py	Tue Jun 19 18:21:37 2018 +0200
+++ b/mercurial/progress.py	Tue Jun 19 22:06:28 2018 -0700
@@ -265,8 +265,7 @@
 
     def progress(self, topic, pos, item='', unit='', total=None):
         now = time.time()
-        self._refreshlock.acquire()
-        try:
+        with self._refreshlock:
             if pos is None:
                 self.starttimes.pop(topic, None)
                 self.startvals.pop(topic, None)
@@ -298,5 +297,3 @@
                     if self._oktoprint(now):
                         self.lastprint = now
                         self.show(now, topic, *self.topicstates[topic])
-        finally:
-            self._refreshlock.release()