[Reproducible-commits] [diffoscope] 19/21: Use nicer with ..._lock: syntax
Joachim Breitner
nomeata at moszumanska.debian.org
Thu Dec 3 15:05:06 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 e29ba5fab719c915282fde32ec988e3c81ead8b8
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 5fbd4da..95cb4d0 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