Skip to content

Simplify lock acquire #5695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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