Skip to content
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

executor: execute parallel unsafe ops serially #3099

Merged
merged 1 commit into from
Oct 6, 2020
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
19 changes: 19 additions & 0 deletions poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,33 @@ def execute(self, operations): # type: (Operation) -> int
self._sections = OrderedDict()
for _, group in groups:
tasks = []
serial_operations = []
for operation in group:
if self._shutdown:
break

# Some operations are unsafe, we mus execute them serially in a group
# https://github.com/python-poetry/poetry/issues/3086
# https://github.com/python-poetry/poetry/issues/2658
#
# We need to explicitly check source type here, see:
# https://github.com/python-poetry/poetry-core/pull/98
is_parallel_unsafe = operation.job_type == "uninstall" or (
operation.package.develop
and operation.package.source_type in {"directory", "git"}
)
if not operation.skipped and is_parallel_unsafe:
serial_operations.append(operation)
continue

tasks.append(self._executor.submit(self._execute_operation, operation))

try:
wait(tasks)

for operation in serial_operations:
wait([self._executor.submit(self._execute_operation, operation)])
abn marked this conversation as resolved.
Show resolved Hide resolved

except KeyboardInterrupt:
self._shutdown = True

Expand Down