Commit 001bcee
committed
Fix log file mixing issue by using ProcessPoolExecutor
The build workflow was experiencing log file corruption and I/O errors due to
concurrent builds writing to the wrong log files. This was caused by using
ThreadPoolExecutor with contextlib.redirect_stdout/stderr, which only provides
thread-local redirection of Python-level writes.
The SDK's build() function spawns subprocesses and uses logger.info()/warning()
to output build logs. Logger handlers write to process-wide file descriptors,
not thread-local redirected streams, causing output from concurrent threads to:
- Write to the wrong log files
- Attempt writing to closed file handles
- Result in ValueError('I/O operation on closed file.')
Solution: Replace ThreadPoolExecutor with ProcessPoolExecutor to provide
complete process-level isolation with separate stdout/stderr/logging per
build. The additional overhead is negligible compared to Docker build time.
Changes:
- Import ProcessPoolExecutor instead of ThreadPoolExecutor
- Move build_one_fn to module level (_build_with_logging) for pickle support
- Update executor initialization to use ProcessPoolExecutor
- Add explanatory comments about isolation requirements
Co-authored-by: openhands <[email protected]>1 parent cdd7200 commit 001bcee
1 file changed
+19
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
165 | 178 | | |
166 | 179 | | |
167 | 180 | | |
| |||
191 | 204 | | |
192 | 205 | | |
193 | 206 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | 207 | | |
201 | 208 | | |
202 | 209 | | |
| |||
212 | 219 | | |
213 | 220 | | |
214 | 221 | | |
215 | | - | |
216 | | - | |
217 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 | | |
219 | 227 | | |
220 | 228 | | |
221 | | - | |
| 229 | + | |
222 | 230 | | |
223 | 231 | | |
224 | 232 | | |
| |||
0 commit comments