[Reproducible-commits] [diffoscope] 01/03: Use nicer with ..._lock: syntax

Joachim Breitner nomeata at moszumanska.debian.org
Thu Dec 3 12:23:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

nomeata pushed a commit to branch pu/parallel2
in repository diffoscope.

commit ab26b70763edea20454b22f61f0fceb1d9084704
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Thu Dec 3 13:21:42 2015 +0100

    Use nicer with ..._lock: syntax
---
 diffoscope/comparators/binary.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/diffoscope/comparators/binary.py b/diffoscope/comparators/binary.py
index 3b57526..c2c8622 100644
--- a/diffoscope/comparators/binary.py
+++ b/diffoscope/comparators/binary.py
@@ -69,10 +69,8 @@ class File(object, metaclass=ABCMeta):
                 self._mimedb = magic.open(magic.NONE)
                 self._mimedb.load()
                 self._mimedb_lock = Lock()
-            self._mimedb_lock.acquire()
-            file_type = self._mimedb.file(path)
-            self._mimedb_lock.release()
-            return file_type
+            with self._mimedb_lock:
+                return self._mimedb.file(path)
 
         @classmethod
         def guess_encoding(self, path):
@@ -80,10 +78,8 @@ class File(object, metaclass=ABCMeta):
                 self._mimedb_encoding = magic.open(magic.MAGIC_MIME_ENCODING)
                 self._mimedb_encoding.load()
                 self._mimedb_encoding_lock = Lock()
-            self._mimedb_encoding_lock.acquire()
-            encoding = self._mimedb_encoding.file(path)
-            self._mimedb_encoding_lock.release()
-            return encoding
+            with self._mimedb_encoding_lock:
+                return self._mimedb_encoding.file(path)
 
     else: # use python-magic
         @classmethod

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list