[Reproducible-commits] [diffoscope] 15/21: File.guess_file_type: Protect access to mimedb
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 c4e1e34e523e12a0ea967e8d3ab4b23106cea28b
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Thu Dec 3 12:24:28 2015 +0100
File.guess_file_type: Protect access to mimedb
---
diffoscope/comparators/binary.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/diffoscope/comparators/binary.py b/diffoscope/comparators/binary.py
index fa1258a..35868e4 100644
--- a/diffoscope/comparators/binary.py
+++ b/diffoscope/comparators/binary.py
@@ -22,6 +22,7 @@ from binascii import hexlify
from contextlib import contextmanager
from functools import wraps
from io import StringIO
+from threading import Lock
import itertools
import os
import os.path
@@ -67,7 +68,11 @@ class File(object, metaclass=ABCMeta):
if not hasattr(self, '_mimedb'):
self._mimedb = magic.open(magic.NONE)
self._mimedb.load()
- return self._mimedb.file(path)
+ self._mimedb_lock = Lock()
+ self._mimedb_lock.acquire()
+ file_type = self._mimedb.file(path)
+ self._mimedb_lock.release()
+ return file_type
@classmethod
def guess_encoding(self, path):
--
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