File fix-locking.patch of Package python-Sphinx
diff --git a/setup.py b/setup.py
index 23e708727..eec691aa2 100644
--- a/setup.py
+++ b/setup.py
@@ -22,6 +22,7 @@ install_requires = [
'snowballstemmer>=1.1',
'babel>=1.3,!=2.0',
'alabaster>=0.7,<0.8',
+ 'filelock',
'imagesize',
'requests>=2.0.0',
'setuptools',
diff --git a/sphinx/application.py b/sphinx/application.py
index 7af1c8d39..0683598a7 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -21,6 +21,7 @@ from os import path
from docutils import nodes
from docutils.parsers.rst import directives, roles
+from filelock import FileLock
from six import iteritems, itervalues
from six.moves import cStringIO
@@ -129,6 +130,7 @@ class Sphinx(object):
self.doctreedir = doctreedir
self.parallel = parallel
+ self.lock = FileLock(path.join(self.doctreedir, "globallock"))
if status is None:
self._status = cStringIO() # type: IO
@@ -227,10 +229,11 @@ class Sphinx(object):
self.config.check_types()
# set up source_parsers
self._init_source_parsers()
- # set up the build environment
- self._init_env(freshenv)
- # set up the builder
- self._init_builder()
+ with self.lock:
+ # set up the build environment
+ self._init_env(freshenv)
+ # set up the builder
+ self._init_builder()
# set up the enumerable nodes
self._init_enumerable_nodes()