Skip to content

Commit 2f5f4da

Browse files
committed
Simplify lock acquire
Currently we are acquiring 3 locks. We should only have 2 (we can't have only one because of readthedocs#5672)
1 parent 843ce09 commit 2f5f4da

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

readthedocs/projects/tasks.py

+21-22
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,12 @@ def run_build(self, docker, record):
560560
)
561561

562562
try:
563-
self.setup_python_environment()
563+
with self.project.repo_nonblockinglock(version=self.version):
564+
self.setup_python_environment()
564565

565-
# TODO the build object should have an idea of these states,
566-
# extend the model to include an idea of these outcomes
567-
outcomes = self.build_docs()
566+
# TODO the build object should have an idea of these states,
567+
# extend the model to include an idea of these outcomes
568+
outcomes = self.build_docs()
568569
except vcs_support_utils.LockTimeout as e:
569570
self.task.retry(exc=e, throw=False)
570571
raise VersionLockedError
@@ -912,19 +913,18 @@ def setup_python_environment(self):
912913
"""
913914
self.build_env.update_build(state=BUILD_STATE_INSTALLING)
914915

915-
with self.project.repo_nonblockinglock(version=self.version):
916-
# Check if the python version/build image in the current venv is the
917-
# same to be used in this build and if it differs, wipe the venv to
918-
# avoid conflicts.
919-
if self.python_env.is_obsolete:
920-
self.python_env.delete_existing_venv_dir()
921-
else:
922-
self.python_env.delete_existing_build_dir()
916+
# Check if the python version/build image in the current venv is the
917+
# same to be used in this build and if it differs, wipe the venv to
918+
# avoid conflicts.
919+
if self.python_env.is_obsolete:
920+
self.python_env.delete_existing_venv_dir()
921+
else:
922+
self.python_env.delete_existing_build_dir()
923923

924-
self.python_env.setup_base()
925-
self.python_env.save_environment_json()
926-
self.python_env.install_core_requirements()
927-
self.python_env.install_requirements()
924+
self.python_env.setup_base()
925+
self.python_env.save_environment_json()
926+
self.python_env.install_core_requirements()
927+
self.python_env.install_requirements()
928928

929929
def build_docs(self):
930930
"""
@@ -941,12 +941,11 @@ def build_docs(self):
941941
before_build.send(sender=self.version)
942942

943943
outcomes = defaultdict(lambda: False)
944-
with self.project.repo_nonblockinglock(version=self.version):
945-
outcomes['html'] = self.build_docs_html()
946-
outcomes['search'] = self.build_docs_search()
947-
outcomes['localmedia'] = self.build_docs_localmedia()
948-
outcomes['pdf'] = self.build_docs_pdf()
949-
outcomes['epub'] = self.build_docs_epub()
944+
outcomes['html'] = self.build_docs_html()
945+
outcomes['search'] = self.build_docs_search()
946+
outcomes['localmedia'] = self.build_docs_localmedia()
947+
outcomes['pdf'] = self.build_docs_pdf()
948+
outcomes['epub'] = self.build_docs_epub()
950949

951950
after_build.send(sender=self.version)
952951
return outcomes

0 commit comments

Comments
 (0)