Skip to content

Commit

Permalink
Merge pull request #5695 from stsewd/simplify-lock-calls
Browse files Browse the repository at this point in the history
Simplify lock acquire
  • Loading branch information
stsewd committed May 16, 2019
2 parents e69167c + 2f5f4da commit 616a303
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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
Expand Down

0 comments on commit 616a303

Please sign in to comment.