Skip to content

Commit b1e7f4f

Browse files
committed
executor: execute parallel unsafe ops serially
Resolves: #2658 #3086
1 parent f2d53e5 commit b1e7f4f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

poetry/installation/executor.py

+16
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,30 @@ def execute(self, operations): # type: (Operation) -> int
107107
self._sections = OrderedDict()
108108
for _, group in groups:
109109
tasks = []
110+
serial_operations = []
110111
for operation in group:
111112
if self._shutdown:
112113
break
113114

115+
# Some operations are unsafe, we mus execute them serially in a group
116+
# https://github.com/python-poetry/poetry/issues/3086
117+
# https://github.com/python-poetry/poetry/issues/2658
118+
is_parallel_unsafe = operation.job_type == "uninstall" or (
119+
operation.package.develop
120+
and operation.package.source_type == "directory"
121+
)
122+
if not operation.skipped and is_parallel_unsafe:
123+
serial_operations.append(operation)
124+
continue
125+
114126
tasks.append(self._executor.submit(self._execute_operation, operation))
115127

116128
try:
117129
wait(tasks)
130+
131+
for operation in serial_operations:
132+
wait([self._executor.submit(self._execute_operation, operation)])
133+
118134
except KeyboardInterrupt:
119135
self._shutdown = True
120136

0 commit comments

Comments
 (0)