From 2f5f4da946104c5c4d3892a248c9c568b749301b Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 14 May 2019 01:05:27 -0500 Subject: [PATCH] Simplify lock acquire Currently we are acquiring 3 locks. We should only have 2 (we can't have only one because of #5672) --- readthedocs/projects/tasks.py | 43 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py index 4291f1dbc05..f7197b38066 100644 --- a/readthedocs/projects/tasks.py +++ b/readthedocs/projects/tasks.py @@ -560,11 +560,12 @@ def run_build(self, docker, record): ) try: - self.setup_python_environment() + with self.project.repo_nonblockinglock(version=self.version): + self.setup_python_environment() - # TODO the build object should have an idea of these states, - # extend the model to include an idea of these outcomes - outcomes = self.build_docs() + # TODO the build object should have an idea of these states, + # extend the model to include an idea of these outcomes + outcomes = self.build_docs() except vcs_support_utils.LockTimeout as e: self.task.retry(exc=e, throw=False) raise VersionLockedError @@ -912,19 +913,18 @@ def setup_python_environment(self): """ self.build_env.update_build(state=BUILD_STATE_INSTALLING) - with self.project.repo_nonblockinglock(version=self.version): - # Check if the python version/build image in the current venv is the - # same to be used in this build and if it differs, wipe the venv to - # avoid conflicts. - if self.python_env.is_obsolete: - self.python_env.delete_existing_venv_dir() - else: - self.python_env.delete_existing_build_dir() + # Check if the python version/build image in the current venv is the + # same to be used in this build and if it differs, wipe the venv to + # avoid conflicts. + if self.python_env.is_obsolete: + self.python_env.delete_existing_venv_dir() + else: + self.python_env.delete_existing_build_dir() - self.python_env.setup_base() - self.python_env.save_environment_json() - self.python_env.install_core_requirements() - self.python_env.install_requirements() + self.python_env.setup_base() + self.python_env.save_environment_json() + self.python_env.install_core_requirements() + self.python_env.install_requirements() def build_docs(self): """ @@ -941,12 +941,11 @@ def build_docs(self): before_build.send(sender=self.version) outcomes = defaultdict(lambda: False) - with self.project.repo_nonblockinglock(version=self.version): - outcomes['html'] = self.build_docs_html() - outcomes['search'] = self.build_docs_search() - outcomes['localmedia'] = self.build_docs_localmedia() - outcomes['pdf'] = self.build_docs_pdf() - outcomes['epub'] = self.build_docs_epub() + outcomes['html'] = self.build_docs_html() + outcomes['search'] = self.build_docs_search() + outcomes['localmedia'] = self.build_docs_localmedia() + outcomes['pdf'] = self.build_docs_pdf() + outcomes['epub'] = self.build_docs_epub() after_build.send(sender=self.version) return outcomes