Commit ba088c8
* gh-71936: Fix race condition in multiprocessing.Pool
Proxes of shared objects register a Finalizer in BaseProxy._incref(), and it
will call BaseProxy._decref() when it is GCed. This may cause a race condition
with Pool(maxtasksperchild=None) on Windows.
A connection would be closed and raised TypeError when a GC occurs between
_ConnectionBase._check_writable() and _ConnectionBase._send_bytes() in
_ConnectionBase.send() in the second or later task, and a new object
is allocated that shares the id() of a previously deleted one.
Instead of using the id() of the token (or the proxy), use a unique,
non-reusable number.
Co-Authored-By: Akinori Hattori <[email protected]>
1 parent 1e40c5b commit ba088c8
File tree
3 files changed
+22
-13
lines changed- Lib/multiprocessing
- Misc
- NEWS.d/next/Library
3 files changed
+22
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
762 | 766 | | |
763 | 767 | | |
764 | 768 | | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
769 | 776 | | |
770 | 777 | | |
771 | 778 | | |
772 | | - | |
| 779 | + | |
773 | 780 | | |
774 | | - | |
775 | | - | |
| 781 | + | |
| 782 | + | |
776 | 783 | | |
777 | | - | |
| 784 | + | |
778 | 785 | | |
779 | 786 | | |
780 | 787 | | |
| |||
857 | 864 | | |
858 | 865 | | |
859 | 866 | | |
860 | | - | |
| 867 | + | |
861 | 868 | | |
862 | 869 | | |
863 | 870 | | |
864 | 871 | | |
865 | 872 | | |
866 | | - | |
867 | | - | |
| 873 | + | |
| 874 | + | |
868 | 875 | | |
869 | 876 | | |
870 | 877 | | |
871 | 878 | | |
872 | | - | |
873 | | - | |
| 879 | + | |
| 880 | + | |
874 | 881 | | |
875 | 882 | | |
876 | 883 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
736 | 737 | | |
737 | 738 | | |
738 | 739 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments