Commit 356de02
authored
gh-109047: concurrent.futures catches PythonFinalizationError (#109810)
concurrent.futures: The *executor manager thread* now catches
exceptions when adding an item to the *call queue*. During Python
finalization, creating a new thread can now raise RuntimeError. Catch
the exception and call terminate_broken() in this case.
Add test_python_finalization_error() to test_concurrent_futures.
concurrent.futures._ExecutorManagerThread changes:
* terminate_broken() no longer calls shutdown_workers() since the
call queue is no longer working anymore (read and write ends of
the queue pipe are closed).
* terminate_broken() now terminates child processes, not only
wait until they complete.
* _ExecutorManagerThread.terminate_broken() now holds shutdown_lock
to prevent race conditons with ProcessPoolExecutor.submit().
multiprocessing.Queue changes:
* Add _terminate_broken() method.
* _start_thread() sets _thread to None on exception to prevent
leaking "dangling threads" even if the thread was not started
yet.
(cherry picked from commit 6351842)
1 parent 41eb0c7 commit 356de02
File tree
4 files changed
+90
-17
lines changed- Lib
- concurrent/futures
- multiprocessing
- test/test_concurrent_futures
- Misc/NEWS.d/next/Library
4 files changed
+90
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
345 | 352 | | |
346 | 353 | | |
347 | 354 | | |
| |||
425 | 432 | | |
426 | 433 | | |
427 | 434 | | |
428 | | - | |
429 | | - | |
| 435 | + | |
| 436 | + | |
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
| |||
473 | 480 | | |
474 | 481 | | |
475 | 482 | | |
476 | | - | |
| 483 | + | |
477 | 484 | | |
478 | 485 | | |
479 | 486 | | |
| |||
498 | 505 | | |
499 | 506 | | |
500 | 507 | | |
501 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
502 | 516 | | |
503 | 517 | | |
504 | 518 | | |
| |||
508 | 522 | | |
509 | 523 | | |
510 | 524 | | |
511 | | - | |
512 | | - | |
513 | | - | |
| 525 | + | |
514 | 526 | | |
515 | 527 | | |
516 | 528 | | |
517 | 529 | | |
518 | 530 | | |
519 | 531 | | |
520 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
521 | 537 | | |
522 | 538 | | |
523 | 539 | | |
| |||
560 | 576 | | |
561 | 577 | | |
562 | 578 | | |
563 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
564 | 587 | | |
565 | 588 | | |
566 | 589 | | |
567 | | - | |
568 | | - | |
| 590 | + | |
| 591 | + | |
569 | 592 | | |
570 | 593 | | |
571 | 594 | | |
| 595 | + | |
| 596 | + | |
572 | 597 | | |
573 | 598 | | |
574 | 599 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| |||
169 | 178 | | |
170 | 179 | | |
171 | 180 | | |
172 | | - | |
| 181 | + | |
| 182 | + | |
173 | 183 | | |
174 | | - | |
175 | 184 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
179 | 194 | | |
180 | 195 | | |
181 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
190 | 219 | | |
191 | 220 | | |
192 | 221 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments