Skip to content

Commit

Permalink
executor: execute parallel unsafe ops serially
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Oct 6, 2020
1 parent 27858e8 commit a743103
Showing 1 changed file with 19 additions and 0 deletions.
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)])

except KeyboardInterrupt:
self._shutdown = True

Expand Down

0 comments on commit a743103

Please sign in to comment.