File: README_MODS

package info (click to toggle)
multiprocess 0.70.19-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,548 kB
  • sloc: python: 82,952; ansic: 9,315; makefile: 16
file content (2682 lines) | stat: -rw-r--r-- 101,213 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
cp -rf py3.12/examples .
cp -rf py3.12/doc .
cp -f py3.12/index.html .
cp -rf py3.12/_multiprocess _multiprocess
cp -rf Python-3.13.0a1/Modules/_multiprocessing Modules/_multiprocess
cp -rf py3.12/multiprocess multiprocess
# ----------------------------------------------------------------------
diff Python-3.13.0a1/Modules/_multiprocessing/semaphore.c Modules/_multiprocess/semaphore.c
10c10
< #include "multiprocessing.h"
---
> #include "multiprocess.h"
39,40c39,40
< module _multiprocessing
< class _multiprocessing.SemLock "SemLockObject *" "&_PyMp_SemLockType"
---
> module _multiprocess
> class _multiprocess.SemLock "SemLockObject *" "&_PyMp_SemLockType"
84c84
< _multiprocessing.SemLock.acquire
---
> _multiprocess.SemLock.acquire
93c93
< _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
---
> _multiprocess_SemLock_acquire_impl(SemLockObject *self, int blocking,
175c175
< _multiprocessing.SemLock.release
---
> _multiprocess.SemLock.release
181c181
< _multiprocessing_SemLock_release_impl(SemLockObject *self)
---
> _multiprocess_SemLock_release_impl(SemLockObject *self)
300c300
< _multiprocessing.SemLock.acquire
---
> _multiprocess.SemLock.acquire
309c309
< _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
---
> _multiprocess_SemLock_acquire_impl(SemLockObject *self, int blocking,
385c385
< _multiprocessing.SemLock.release
---
> _multiprocess.SemLock.release
391c391
< _multiprocessing_SemLock_release_impl(SemLockObject *self)
---
> _multiprocess_SemLock_release_impl(SemLockObject *self)
475c475
< _multiprocessing.SemLock.__new__
---
> _multiprocess.SemLock.__new__
486c486
< _multiprocessing_SemLock_impl(PyTypeObject *type, int kind, int value,
---
> _multiprocess_SemLock_impl(PyTypeObject *type, int kind, int value,
534c534
< _multiprocessing.SemLock._rebuild
---
> _multiprocess.SemLock._rebuild
545c545
< _multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle,
---
> _multiprocess_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle,
586c586
< _multiprocessing.SemLock._count
---
> _multiprocess.SemLock._count
592c592
< _multiprocessing_SemLock__count_impl(SemLockObject *self)
---
> _multiprocess_SemLock__count_impl(SemLockObject *self)
599c599
< _multiprocessing.SemLock._is_mine
---
> _multiprocess.SemLock._is_mine
605c605
< _multiprocessing_SemLock__is_mine_impl(SemLockObject *self)
---
> _multiprocess_SemLock__is_mine_impl(SemLockObject *self)
613c613
< _multiprocessing.SemLock._get_value
---
> _multiprocess.SemLock._get_value
619c619
< _multiprocessing_SemLock__get_value_impl(SemLockObject *self)
---
> _multiprocess_SemLock__get_value_impl(SemLockObject *self)
638c638
< _multiprocessing.SemLock._is_zero
---
> _multiprocess.SemLock._is_zero
644c644
< _multiprocessing_SemLock__is_zero_impl(SemLockObject *self)
---
> _multiprocess_SemLock__is_zero_impl(SemLockObject *self)
666c666
< _multiprocessing.SemLock._after_fork
---
> _multiprocess.SemLock._after_fork
672c672
< _multiprocessing_SemLock__after_fork_impl(SemLockObject *self)
---
> _multiprocess_SemLock__after_fork_impl(SemLockObject *self)
680c680
< _multiprocessing.SemLock.__enter__
---
> _multiprocess.SemLock.__enter__
686c686
< _multiprocessing_SemLock___enter___impl(SemLockObject *self)
---
> _multiprocess_SemLock___enter___impl(SemLockObject *self)
689c689
<     return _multiprocessing_SemLock_acquire_impl(self, 1, Py_None);
---
>     return _multiprocess_SemLock_acquire_impl(self, 1, Py_None);
693c693
< _multiprocessing.SemLock.__exit__
---
> _multiprocess.SemLock.__exit__
704c704
< _multiprocessing_SemLock___exit___impl(SemLockObject *self,
---
> _multiprocess_SemLock___exit___impl(SemLockObject *self,
709c709
<     return _multiprocessing_SemLock_release_impl(self);
---
>     return _multiprocess_SemLock_release_impl(self);
724,733c724,733
<     _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF
<     _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF
<     _MULTIPROCESSING_SEMLOCK___ENTER___METHODDEF
<     _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
<     _MULTIPROCESSING_SEMLOCK__COUNT_METHODDEF
<     _MULTIPROCESSING_SEMLOCK__IS_MINE_METHODDEF
<     _MULTIPROCESSING_SEMLOCK__GET_VALUE_METHODDEF
<     _MULTIPROCESSING_SEMLOCK__IS_ZERO_METHODDEF
<     _MULTIPROCESSING_SEMLOCK__REBUILD_METHODDEF
<     _MULTIPROCESSING_SEMLOCK__AFTER_FORK_METHODDEF
---
>     _MULTIPROCESS_SEMLOCK_ACQUIRE_METHODDEF
>     _MULTIPROCESS_SEMLOCK_RELEASE_METHODDEF
>     _MULTIPROCESS_SEMLOCK___ENTER___METHODDEF
>     _MULTIPROCESS_SEMLOCK___EXIT___METHODDEF
>     _MULTIPROCESS_SEMLOCK__COUNT_METHODDEF
>     _MULTIPROCESS_SEMLOCK__IS_MINE_METHODDEF
>     _MULTIPROCESS_SEMLOCK__GET_VALUE_METHODDEF
>     _MULTIPROCESS_SEMLOCK__IS_ZERO_METHODDEF
>     _MULTIPROCESS_SEMLOCK__REBUILD_METHODDEF
>     _MULTIPROCESS_SEMLOCK__AFTER_FORK_METHODDEF
764c764
<     {Py_tp_new, _multiprocessing_SemLock},
---
>     {Py_tp_new, _multiprocess_SemLock},
772c772
<     .name = "_multiprocessing.SemLock",
---
>     .name = "_multiprocess.SemLock",
diff Python-3.13.0a1/Modules/_multiprocessing/multiprocessing.h Modules/_multiprocess/multiprocess.h 
1,2c1,2
< #ifndef MULTIPROCESSING_H
< #define MULTIPROCESSING_H
---
> #ifndef MULTIPROCESS_H
> #define MULTIPROCESS_H
104c104
< #endif /* MULTIPROCESSING_H */
---
> #endif /* MULTIPROCESS_H */
diff Python-3.13.0a1/Modules/_multiprocessing/multiprocessing.c Modules/_multiprocess/multiprocess.c
2c2
<  * Extension module used by multiprocessing package
---
>  * Extension module used by multiprocess package
4c4
<  * multiprocessing.c
---
>  * multiprocess.c
10c10
< #include "multiprocessing.h"
---
> #include "multiprocess.h"
30c30
< module _multiprocessing
---
> module _multiprocess
77c77
< _multiprocessing.closesocket
---
> _multiprocess.closesocket
85c85
< _multiprocessing_closesocket_impl(PyObject *module, HANDLE handle)
---
> _multiprocess_closesocket_impl(PyObject *module, HANDLE handle)
100c100
< _multiprocessing.recv
---
> _multiprocess.recv
109c109
< _multiprocessing_recv_impl(PyObject *module, HANDLE handle, int size)
---
> _multiprocess_recv_impl(PyObject *module, HANDLE handle, int size)
132c132
< _multiprocessing.send
---
> _multiprocess.send
141c141
< _multiprocessing_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf)
---
> _multiprocess_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf)
160c160
< _multiprocessing.sem_unlink
---
> _multiprocess.sem_unlink
168c168
< _multiprocessing_sem_unlink_impl(PyObject *module, const char *name)
---
> _multiprocess_sem_unlink_impl(PyObject *module, const char *name)
196c196
< multiprocessing_exec(PyObject *module)
---
> multiprocess_exec(PyObject *module)
277,278c277,278
< static PyModuleDef_Slot multiprocessing_slots[] = {
<     {Py_mod_exec, multiprocessing_exec},
---
> static PyModuleDef_Slot multiprocess_slots[] = {
>     {Py_mod_exec, multiprocess_exec},
283c283
< static struct PyModuleDef multiprocessing_module = {
---
> static struct PyModuleDef multiprocess_module = {
285c285
<     .m_name = "_multiprocessing",
---
>     .m_name = "_multiprocess",
288c288
<     .m_slots = multiprocessing_slots,
---
>     .m_slots = multiprocess_slots,
292c292
< PyInit__multiprocessing(void)
---
> PyInit__multiprocess(void)
294c294
<     return PyModuleDef_Init(&multiprocessing_module);
---
>     return PyModuleDef_Init(&multiprocess_module);
# ----------------------------------------------------------------------
diff Python-3.12.0rc3/Lib/multiprocessing/connection.py Python-3.13.0a1/Lib/multiprocessing/connection.py
11a12
> import errno
273a275
>         _send_ov = None
275a278,281
>             ov = self._send_ov
>             if ov is not None:
>                 # Interrupt WaitForMultipleObjects() in _send_bytes()
>                 ov.cancel()
278a285,288
>             if self._send_ov is not None:
>                 # A connection should only be used by a single thread
>                 raise ValueError("concurrent send_bytes() calls "
>                                  "are not supported")
279a290
>             self._send_ov = ov
288a300
>                 self._send_ov = None
289a302,306
>             if err == _winapi.ERROR_OPERATION_ABORTED:
>                 # close() was called by another thread while
>                 # WaitForMultipleObjects() was waiting for the overlapped
>                 # operation.
>                 raise OSError(errno.EPIPE, "handle is closed")
diff Python-3.12.0rc3/Lib/multiprocessing/managers.py Python-3.13.0a1/Lib/multiprocessing/managers.py
93c93,96
<     raise convert_to_error(kind, result)
---
>     try:
>         raise convert_to_error(kind, result)
>     finally:
>         del result  # break reference cycle
836c839,842
<         raise convert_to_error(kind, result)
---
>         try:
>             raise convert_to_error(kind, result)
>         finally:
>             del result   # break reference cycle
diff Python-3.12.0rc3/Lib/multiprocessing/pool.py Python-3.13.0a1/Lib/multiprocessing/pool.py
203c203
<             processes = os.cpu_count() or 1
---
>             processes = os.process_cpu_count() or 1
diff Python-3.12.0rc3/Lib/multiprocessing/popen_spawn_win32.py Python-3.13.0a1/Lib/multiprocessing/popen_spawn_win32.py
16a17
> # Exit code used by Popen.terminate()
125,126c126,130
<             except OSError:
<                 if self.wait(timeout=1.0) is None:
---
>             except PermissionError:
>                 # ERROR_ACCESS_DENIED (winerror 5) is received when the
>                 # process already died.
>                 code = _winapi.GetExitCodeProcess(int(self._handle))
>                 if code == _winapi.STILL_ACTIVE:
127a132,134
>                 self.returncode = code
>             else:
>                 self.returncode = -signal.SIGTERM
diff Python-3.12.0rc3/Lib/multiprocessing/queues.py Python-3.13.0a1/Lib/multiprocessing/queues.py
160a161,174
>     def _terminate_broken(self):
>         # Close a Queue on error.
> 
>         # gh-94777: Prevent queue writing to a pipe which is no longer read.
>         self._reader.close()
> 
>         # gh-107219: Close the connection writer which can unblock
>         # Queue._feed() if it was stuck in send_bytes().
>         if sys.platform == 'win32':
>             self._writer.close()
> 
>         self.close()
>         self.join_thread()
> 
172c186,187
<             name='QueueFeederThread'
---
>             name='QueueFeederThread',
>             daemon=True,
174d188
<         self._thread.daemon = True
176,178c190,198
<         debug('doing self._thread.start()')
<         self._thread.start()
<         debug('... done self._thread.start()')
---
>         try:
>             debug('doing self._thread.start()')
>             self._thread.start()
>             debug('... done self._thread.start()')
>         except:
>             # gh-109047: During Python finalization, creating a thread
>             # can fail with RuntimeError.
>             self._thread = None
>             raise
diff Python-3.12.0rc3/Lib/multiprocessing/resource_tracker.py Python-3.13.0a1/Lib/multiprocessing/resource_tracker.py
53a54,57
> class ReentrantCallError(RuntimeError):
>     pass
> 
> 
57c61
<         self._lock = threading.Lock()
---
>         self._lock = threading.RLock()
60a65,72
>     def _reentrant_call_error(self):
>         # gh-109629: this happens if an explicit call to the ResourceTracker
>         # gets interrupted by a garbage collection, invoking a finalizer (*)
>         # that itself calls back into ResourceTracker.
>         #   (*) for example the SemLock finalizer
>         raise ReentrantCallError(
>             "Reentrant call into the multiprocessing resource tracker")
> 
62a75,78
>             # This should not happen (_stop() isn't called by a finalizer)
>             # but we check for it anyway.
>             if self._lock._recursion_count() > 1:
>                 return self._reentrant_call_error()
83a100,102
>             if self._lock._recursion_count() > 1:
>                 # The code below is certainly not reentrant-safe, so bail out
>                 return self._reentrant_call_error()
162c181,191
<         self.ensure_running()
---
>         try:
>             self.ensure_running()
>         except ReentrantCallError:
>             # The code below might or might not work, depending on whether
>             # the resource tracker was already running and still alive.
>             # Better warn the user.
>             # (XXX is warnings.warn itself reentrant-safe? :-)
>             warnings.warn(
>                 f"ResourceTracker called reentrantly for resource cleanup, "
>                 f"which is unsupported. "
>                 f"The {rtype} object {name!r} might leak.")
178a208
> 
224,226c254,257
<                     warnings.warn('resource_tracker: There appear to be %d '
<                                   'leaked %s objects to clean up at shutdown' %
<                                   (len(rtype_cache), rtype))
---
>                     warnings.warn(
>                         f'resource_tracker: There appear to be {len(rtype_cache)} '
>                         f'leaked {rtype} objects to clean up at shutdown: {rtype_cache}'
>                     )
diff Python-3.12.0rc3/Lib/multiprocessing/util.py Python-3.13.0a1/Lib/multiprocessing/util.py
67,68c67
<     logging._acquireLock()
<     try:
---
>     with logging._lock:
82,84d80
<     finally:
<         logging._releaseLock()
< 
# ----------------------------------------------------------------------
diff Python-3.12.0rc3/Lib/test/_test_multiprocessing.py Python-3.13.0a1/Lib/test/_test_multiprocessing.py 
53c53
< from multiprocessing.connection import wait, AuthenticationError
---
> from multiprocessing.connection import wait
81,82c81,82
< if support.check_sanitizer(address=True):
<     # bpo-45200: Skip multiprocessing tests if Python is built with ASAN to
---
> if support.HAVE_ASAN_FORK_BUG:
>     # gh-89363: Skip multiprocessing tests if Python is built with ASAN to
84c84,89
<     raise unittest.SkipTest("libasan has a pthread_create() dead lock")
---
>     raise unittest.SkipTest("libasan has a pthread_create() dead lock related to thread+fork")
> 
> 
> # gh-110666: Tolerate a difference of 100 ms when comparing timings
> # (clock resolution)
> CLOCK_RES = 0.100
560,561c565
<         if os.name != 'nt':
<             self.assertEqual(exitcode, -signal.SIGTERM)
---
>         self.assertEqual(exitcode, -signal.SIGTERM)
566a571,572
>         else:
>             self.assertEqual(exitcode, -signal.SIGTERM)
1653c1659
<             expected = 0.1
---
>             expected = 0.100
1657,1658c1663
<             # borrow logic in assertTimeout() from test/lock_tests.py
<             if not result and expected * 0.6 < dt < expected * 10.0:
---
>             if not result and (expected - CLOCK_RES) <= dt:
1677c1682
<             time.sleep(0.01)
---
>             time.sleep(0.010)
2576c2581
<         res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 1.0))
---
>         res = self.pool.apply_async(sqr, (6, TIMEOUT2 + support.SHORT_TIMEOUT))
2680,2682c2685,2687
<         result = self.pool.map_async(
<             time.sleep, [0.1 for i in range(10000)], chunksize=1
<             )
---
>         # Simulate slow tasks which take "forever" to complete
>         args = [support.LONG_TIMEOUT for i in range(10_000)]
>         result = self.pool.map_async(time.sleep, args, chunksize=1)
2684,2687c2689
<         join = TimingWrapper(self.pool.join)
<         join()
<         # Sanity check the pool didn't wait for all tasks to finish
<         self.assertLess(join.elapsed, 2.0)
---
>         self.pool.join()
3153a3156,3193
> 
> class FakeConnection:
>     def send(self, payload):
>         pass
> 
>     def recv(self):
>         return '#ERROR', pyqueue.Empty()
> 
> class TestManagerExceptions(unittest.TestCase):
>     # Issue 106558: Manager exceptions avoids creating cyclic references.
>     def setUp(self):
>         self.mgr = multiprocessing.Manager()
> 
>     def tearDown(self):
>         self.mgr.shutdown()
>         self.mgr.join()
> 
>     def test_queue_get(self):
>         queue = self.mgr.Queue()
>         if gc.isenabled():
>             gc.disable()
>             self.addCleanup(gc.enable)
>         try:
>             queue.get_nowait()
>         except pyqueue.Empty as e:
>             wr = weakref.ref(e)
>         self.assertEqual(wr(), None)
> 
>     def test_dispatch(self):
>         if gc.isenabled():
>             gc.disable()
>             self.addCleanup(gc.enable)
>         try:
>             multiprocessing.managers.dispatch(FakeConnection(), None, None)
>         except pyqueue.Empty as e:
>             wr = weakref.ref(e)
>         self.assertEqual(wr(), None)
> 
4872c4912
<                 time.sleep(random.random()*0.1)
---
>                 time.sleep(random.random() * 0.100)
4912c4952
<                 time.sleep(random.random()*0.1)
---
>                 time.sleep(random.random() * 0.100)
4961c5001
<         expected = 5
---
>         timeout = 5.0  # seconds
4965c5005
<         res = wait([a, b], expected)
---
>         res = wait([a, b], timeout)
4969,4970c5009
<         self.assertLess(delta, expected * 2)
<         self.assertGreater(delta, expected * 0.5)
---
>         self.assertGreater(delta, timeout - CLOCK_RES)
4973,4974d5011
< 
<         start = time.monotonic()
4976,4977d5012
<         delta = time.monotonic() - start
< 
4979d5013
<         self.assertLess(delta, 0.4)
5437c5471,5473
<         self.assertEqual(results, [2, 1])
---
>         # gh-109706: queue.put(1) can write into the queue before queue.put(2),
>         # there is no synchronization in the test.
>         self.assertSetEqual(set(results), set([2, 1]))
# ----------------------------------------------------------------------
diff Python-3.13.0a1/Modules/_multiprocessing/clinic/posixshmem.c.h Python-3.13.0a2/Modules/_multiprocessing/clinic/posixshmem.c.h
5,9d4
< #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
< #  include "pycore_gc.h"          // PyGC_Head
< #  include "pycore_runtime.h"     // _Py_ID()
< #endif
< 
19c14
<     {"shm_open", _PyCFunction_CAST(_posixshmem_shm_open), METH_FASTCALL|METH_KEYWORDS, _posixshmem_shm_open__doc__},
---
>     {"shm_open", (PyCFunction)(void(*)(void))_posixshmem_shm_open, METH_VARARGS|METH_KEYWORDS, _posixshmem_shm_open__doc__},
26c21
< _posixshmem_shm_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
---
> _posixshmem_shm_open(PyObject *module, PyObject *args, PyObject *kwargs)
29,55c24
<     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
< 
<     #define NUM_KEYWORDS 3
<     static struct {
<         PyGC_Head _this_is_not_used;
<         PyObject_VAR_HEAD
<         PyObject *ob_item[NUM_KEYWORDS];
<     } _kwtuple = {
<         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
<         .ob_item = { &_Py_ID(path), &_Py_ID(flags), &_Py_ID(mode), },
<     };
<     #undef NUM_KEYWORDS
<     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
< 
<     #else  // !Py_BUILD_CORE
<     #  define KWTUPLE NULL
<     #endif  // !Py_BUILD_CORE
< 
<     static const char * const _keywords[] = {"path", "flags", "mode", NULL};
<     static _PyArg_Parser _parser = {
<         .keywords = _keywords,
<         .fname = "shm_open",
<         .kwtuple = KWTUPLE,
<     };
<     #undef KWTUPLE
<     PyObject *argsbuf[3];
<     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
---
>     static char *_keywords[] = {"path", "flags", "mode", NULL};
61,78c30,31
<     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
<     if (!args) {
<         goto exit;
<     }
<     if (!PyUnicode_Check(args[0])) {
<         _PyArg_BadArgument("shm_open", "argument 'path'", "str", args[0]);
<         goto exit;
<     }
<     path = args[0];
<     flags = PyLong_AsInt(args[1]);
<     if (flags == -1 && PyErr_Occurred()) {
<         goto exit;
<     }
<     if (!noptargs) {
<         goto skip_optional_pos;
<     }
<     mode = PyLong_AsInt(args[2]);
<     if (mode == -1 && PyErr_Occurred()) {
---
>     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ui|i:shm_open", _keywords,
>         &path, &flags, &mode))
80,81d32
<     }
< skip_optional_pos:
107c58
<     {"shm_unlink", _PyCFunction_CAST(_posixshmem_shm_unlink), METH_FASTCALL|METH_KEYWORDS, _posixshmem_shm_unlink__doc__},
---
>     {"shm_unlink", (PyCFunction)(void(*)(void))_posixshmem_shm_unlink, METH_VARARGS|METH_KEYWORDS, _posixshmem_shm_unlink__doc__},
113c64
< _posixshmem_shm_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
---
> _posixshmem_shm_unlink(PyObject *module, PyObject *args, PyObject *kwargs)
116,141c67
<     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
< 
<     #define NUM_KEYWORDS 1
<     static struct {
<         PyGC_Head _this_is_not_used;
<         PyObject_VAR_HEAD
<         PyObject *ob_item[NUM_KEYWORDS];
<     } _kwtuple = {
<         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
<         .ob_item = { &_Py_ID(path), },
<     };
<     #undef NUM_KEYWORDS
<     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
< 
<     #else  // !Py_BUILD_CORE
<     #  define KWTUPLE NULL
<     #endif  // !Py_BUILD_CORE
< 
<     static const char * const _keywords[] = {"path", NULL};
<     static _PyArg_Parser _parser = {
<         .keywords = _keywords,
<         .fname = "shm_unlink",
<         .kwtuple = KWTUPLE,
<     };
<     #undef KWTUPLE
<     PyObject *argsbuf[1];
---
>     static char *_keywords[] = {"path", NULL};
144,145c70,71
<     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
<     if (!args) {
---
>     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "U:shm_unlink", _keywords,
>         &path))
147,152d72
<     }
<     if (!PyUnicode_Check(args[0])) {
<         _PyArg_BadArgument("shm_unlink", "argument 'path'", "str", args[0]);
<         goto exit;
<     }
<     path = args[0];
168c88
< /*[clinic end generated code: output=2f356903a281d857 input=a9049054013a1b77]*/
---
> /*[clinic end generated code: output=be0661dbed83ea23 input=a9049054013a1b77]*/
diff Python-3.13.0a1/Modules/_multiprocessing/clinic/semaphore.c.h Python-3.13.0a2/Modules/_multiprocessing/clinic/semaphore.c.h
8a9
> #include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
544c545
< /*[clinic end generated code: output=e8ea65f8cba8e173 input=a9049054013a1b77]*/
---
> /*[clinic end generated code: output=d57992037e6770b6 input=a9049054013a1b77]*/
diff Python-3.13.0a1/Modules/_multiprocessing/clinic/multiprocessing.c.h Python-3.13.0a2/Modules/_multiprocessing/clinic/multiprocessing.c.h
4a5,6
> #include "pycore_modsupport.h"    // _PyArg_CheckPositional()
> 
105,108d106
<     if (!PyBuffer_IsContiguous(&buf, 'C')) {
<         _PyArg_BadArgument("send", "argument 2", "contiguous buffer", args[1]);
<         goto exit;
<     }
169c167
< /*[clinic end generated code: output=8b91c020d4353cc5 input=a9049054013a1b77]*/
---
> /*[clinic end generated code: output=73b4cb8428d816da input=a9049054013a1b77]*/
# ----------------------------------------------------------------------
diff Python-3.13.0a1/Modules/_multiprocessing/posixshmem.c Python-3.13.0a2/Modules/_multiprocessing/posixshmem.c
4a5,11
> #include "pyconfig.h"   // Py_GIL_DISABLED
> 
> #ifndef Py_GIL_DISABLED
> // Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
> #define Py_LIMITED_API 0x030c0000
> #endif
> 
7c14
< // for shm_open() and shm_unlink()
---
> #include <errno.h>                // EINTR
9c16
< #include <sys/mman.h>
---
> #  include <sys/mman.h>           // shm_open(), shm_unlink()
11a19
> 
43c51
<     const char *name = PyUnicode_AsUTF8(path);
---
>     const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
82c90
<     const char *name = PyUnicode_AsUTF8(path);
---
>     const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
# ----------------------------------------------------------------------
diff Python-3.13.0a1/Lib/multiprocessing/managers.py Python-3.13.0a2/Lib/multiprocessing/managers.py
1167a1168
>     __class_getitem__ = classmethod(types.GenericAlias)
1169c1170,1171
< DictProxy = MakeProxyType('DictProxy', (
---
> 
> _BaseDictProxy = MakeProxyType('DictProxy', (
1174c1176
< DictProxy._method_to_typeid_ = {
---
> _BaseDictProxy._method_to_typeid_ = {
1176a1179,1180
> class DictProxy(_BaseDictProxy):
>     __class_getitem__ = classmethod(types.GenericAlias)
# ----------------------------------------------------------------------
diff Python-3.13.0a1/Lib/test/_test_multiprocessing.py Python-3.13.0a2/Lib/test/_test_multiprocessing.py 
2441,2442c2441,2445
< def sqr(x, wait=0.0):
<     time.sleep(wait)
---
> def sqr(x, wait=0.0, event=None):
>     if event is None:
>         time.sleep(wait)
>     else:
>         event.wait(wait)
2581,2584c2584,2595
<         res = self.pool.apply_async(sqr, (6, TIMEOUT2 + support.SHORT_TIMEOUT))
<         get = TimingWrapper(res.get)
<         self.assertRaises(multiprocessing.TimeoutError, get, timeout=TIMEOUT2)
<         self.assertTimingAlmostEqual(get.elapsed, TIMEOUT2)
---
>         p = self.Pool(3)
>         try:
>             event = threading.Event() if self.TYPE == 'threads' else None
>             res = p.apply_async(sqr, (6, TIMEOUT2 + support.SHORT_TIMEOUT, event))
>             get = TimingWrapper(res.get)
>             self.assertRaises(multiprocessing.TimeoutError, get, timeout=TIMEOUT2)
>             self.assertTimingAlmostEqual(get.elapsed, TIMEOUT2)
>         finally:
>             if event is not None:
>                 event.set()
>             p.terminate()
>             p.join()
2684a2696,2698
>         if self.TYPE == 'threads':
>             self.skipTest("Threads cannot be terminated")
> 
2685a2700
>         p = self.Pool(3)
2687,2689c2702,2704
<         result = self.pool.map_async(time.sleep, args, chunksize=1)
<         self.pool.terminate()
<         self.pool.join()
---
>         result = p.map_async(time.sleep, args, chunksize=1)
>         p.terminate()
>         p.join()
# ----------------------------------------------------------------------
diff Python-3.13.0a2/Lib/multiprocessing/managers.py Python-3.13.0a3/Lib/multiprocessing/managers.py
159c159
<         self.listener = Listener(address=address, backlog=16)
---
>         self.listener = Listener(address=address, backlog=128)
diff Python-3.13.0a2/Lib/multiprocessing/popen_spawn_win32.py Python-3.13.0a3/Lib/multiprocessing/popen_spawn_win32.py
104,115c104,117
<         if self.returncode is None:
<             if timeout is None:
<                 msecs = _winapi.INFINITE
<             else:
<                 msecs = max(0, int(timeout * 1000 + 0.5))
< 
<             res = _winapi.WaitForSingleObject(int(self._handle), msecs)
<             if res == _winapi.WAIT_OBJECT_0:
<                 code = _winapi.GetExitCodeProcess(self._handle)
<                 if code == TERMINATE:
<                     code = -signal.SIGTERM
<                 self.returncode = code
---
>         if self.returncode is not None:
>             return self.returncode
> 
>         if timeout is None:
>             msecs = _winapi.INFINITE
>         else:
>             msecs = max(0, int(timeout * 1000 + 0.5))
> 
>         res = _winapi.WaitForSingleObject(int(self._handle), msecs)
>         if res == _winapi.WAIT_OBJECT_0:
>             code = _winapi.GetExitCodeProcess(self._handle)
>             if code == TERMINATE:
>                 code = -signal.SIGTERM
>             self.returncode = code
123,134c125,140
<         if self.returncode is None:
<             try:
<                 _winapi.TerminateProcess(int(self._handle), TERMINATE)
<             except PermissionError:
<                 # ERROR_ACCESS_DENIED (winerror 5) is received when the
<                 # process already died.
<                 code = _winapi.GetExitCodeProcess(int(self._handle))
<                 if code == _winapi.STILL_ACTIVE:
<                     raise
<                 self.returncode = code
<             else:
<                 self.returncode = -signal.SIGTERM
---
>         if self.returncode is not None:
>             return
> 
>         try:
>             _winapi.TerminateProcess(int(self._handle), TERMINATE)
>         except PermissionError:
>             # ERROR_ACCESS_DENIED (winerror 5) is received when the
>             # process already died.
>             code = _winapi.GetExitCodeProcess(int(self._handle))
>             if code == _winapi.STILL_ACTIVE:
>                 raise
> 
>         # gh-113009: Don't set self.returncode. Even if GetExitCodeProcess()
>         # returns an exit code different than STILL_ACTIVE, the process can
>         # still be running. Only set self.returncode once WaitForSingleObject()
>         # returns WAIT_OBJECT_0 in wait().
diff Python-3.13.0a2/Lib/multiprocessing/resource_sharer.py Python-3.13.0a3/Lib/multiprocessing/resource_sharer.py
126c126
<         self._listener = Listener(authkey=process.current_process().authkey)
---
>         self._listener = Listener(authkey=process.current_process().authkey, backlog=128)
diff Python-3.13.0a2/Lib/multiprocessing/shared_memory.py Python-3.13.0a3/Lib/multiprocessing/shared_memory.py
73a74
>     _track = True
75c76
<     def __init__(self, name=None, create=False, size=0):
---
>     def __init__(self, name=None, create=False, size=0, *, track=True):
84a86
>         self._track = track
119,120c121,122
< 
<             resource_tracker.register(self._name, "shared_memory")
---
>             if self._track:
>                 resource_tracker.register(self._name, "shared_memory")
239,241c241,250
<         In order to ensure proper cleanup of resources, unlink should be
<         called once (and only once) across all processes which have access
<         to the shared memory block."""
---
>         Unlink should be called once (and only once) across all handles
>         which have access to the shared memory block, even if these
>         handles belong to different processes. Closing and unlinking may
>         happen in any order, but trying to access data inside a shared
>         memory block after unlinking may result in memory errors,
>         depending on platform.
> 
>         This method has no effect on Windows, where the only way to
>         delete a shared memory block is to close all handles."""
> 
244c253,254
<             resource_tracker.unregister(self._name, "shared_memory")
---
>             if self._track:
>                 resource_tracker.unregister(self._name, "shared_memory")
diff Python-3.13.0a2/Lib/multiprocessing/util.py Python-3.13.0a3/Lib/multiprocessing/util.py
46c46
<         _logger.log(SUBDEBUG, msg, *args)
---
>         _logger.log(SUBDEBUG, msg, *args, stacklevel=2)
50c50
<         _logger.log(DEBUG, msg, *args)
---
>         _logger.log(DEBUG, msg, *args, stacklevel=2)
54c54
<         _logger.log(INFO, msg, *args)
---
>         _logger.log(INFO, msg, *args, stacklevel=2)
58c58
<         _logger.log(SUBWARNING, msg, *args)
---
>         _logger.log(SUBWARNING, msg, *args, stacklevel=2)
# ----------------------------------------------------------------------
diff Python-3.13.0a2/Lib/test/_test_multiprocessing.py Python-3.13.0a3/Lib/test/_test_multiprocessing.py 
4457a4458,4510
>     @unittest.skipIf(os.name != "posix", "resource_tracker is posix only")
>     def test_shared_memory_untracking(self):
>         # gh-82300: When a separate Python process accesses shared memory
>         # with track=False, it must not cause the memory to be deleted
>         # when terminating.
>         cmd = '''if 1:
>             import sys
>             from multiprocessing.shared_memory import SharedMemory
>             mem = SharedMemory(create=False, name=sys.argv[1], track=False)
>             mem.close()
>         '''
>         mem = shared_memory.SharedMemory(create=True, size=10)
>         # The resource tracker shares pipes with the subprocess, and so
>         # err existing means that the tracker process has terminated now.
>         try:
>             rc, out, err = script_helper.assert_python_ok("-c", cmd, mem.name)
>             self.assertNotIn(b"resource_tracker", err)
>             self.assertEqual(rc, 0)
>             mem2 = shared_memory.SharedMemory(create=False, name=mem.name)
>             mem2.close()
>         finally:
>             try:
>                 mem.unlink()
>             except OSError:
>                 pass
>             mem.close()
> 
>     @unittest.skipIf(os.name != "posix", "resource_tracker is posix only")
>     def test_shared_memory_tracking(self):
>         # gh-82300: When a separate Python process accesses shared memory
>         # with track=True, it must cause the memory to be deleted when
>         # terminating.
>         cmd = '''if 1:
>             import sys
>             from multiprocessing.shared_memory import SharedMemory
>             mem = SharedMemory(create=False, name=sys.argv[1], track=True)
>             mem.close()
>         '''
>         mem = shared_memory.SharedMemory(create=True, size=10)
>         try:
>             rc, out, err = script_helper.assert_python_ok("-c", cmd, mem.name)
>             self.assertEqual(rc, 0)
>             self.assertIn(
>                 b"resource_tracker: There appear to be 1 leaked "
>                 b"shared_memory objects to clean up at shutdown", err)
>         finally:
>             try:
>                 mem.unlink()
>             except OSError:
>                 pass
>             resource_tracker.unregister(mem._name, "shared_memory")
>             mem.close()
> 
4673a4727,4749
>     def test_filename(self):
>         logger = multiprocessing.get_logger()
>         original_level = logger.level
>         try:
>             logger.setLevel(util.DEBUG)
>             stream = io.StringIO()
>             handler = logging.StreamHandler(stream)
>             logging_format = '[%(levelname)s] [%(filename)s] %(message)s'
>             handler.setFormatter(logging.Formatter(logging_format))
>             logger.addHandler(handler)
>             logger.info('1')
>             util.info('2')
>             logger.debug('3')
>             filename = os.path.basename(__file__)
>             log_record = stream.getvalue()
>             self.assertIn(f'[INFO] [{filename}] 1', log_record)
>             self.assertIn(f'[INFO] [{filename}] 2', log_record)
>             self.assertIn(f'[DEBUG] [{filename}] 3', log_record)
>         finally:
>             logger.setLevel(original_level)
>             logger.removeHandler(handler)
>             handler.close()
> 
# ----------------------------------------------------------------------
diff Python-3.13.0a3/Lib/multiprocessing/connection.py Python-3.13.0a4/Lib/multiprocessing/connection.py
22d21
< import _multiprocessing
30a30
>     import _multiprocessing
1013a1014,1024
>         # Windows limits WaitForMultipleObjects at 64 handles, and we use a
>         # few for synchronisation, so we switch to batched waits at 60.
>         if len(L) > 60:
>             try:
>                 res = _winapi.BatchedWaitForMultipleObjects(L, False, timeout)
>             except TimeoutError:
>                 return []
>             ready.extend(L[i] for i in res)
>             if res:
>                 L = [h for i, h in enumerate(L) if i > res[0] & i not in res]
>             timeout = 0
1015c1026,1027
<             res = _winapi.WaitForMultipleObjects(L, False, timeout)
---
>             short_L = L[:60] if len(L) > 60 else L
>             res = _winapi.WaitForMultipleObjects(short_L, False, timeout)
diff Python-3.13.0a3/Lib/test/_test_multiprocessing.py Python-3.13.0a4/Lib/test/_test_multiprocessing.py 
2695a2696,2698
>         # Simulate slow tasks which take "forever" to complete
>         sleep_time = support.LONG_TIMEOUT
> 
2697c2700,2703
<             self.skipTest("Threads cannot be terminated")
---
>             # Thread pool workers can't be forced to quit, so if the first
>             # task starts early enough, we will end up waiting for it.
>             # Sleep for a shorter time, so the test doesn't block.
>             sleep_time = 1
2699d2704
<         # Simulate slow tasks which take "forever" to complete
2701c2706
<         args = [support.LONG_TIMEOUT for i in range(10_000)]
---
>         args = [sleep_time for i in range(10_000)]
2702a2708
>         time.sleep(0.2)  # give some tasks a chance to start
6109a6116,6133
>     def test_large_pool(self):
>         #
>         # gh-89240: Check that large pools are always okay
>         #
>         testfn = os_helper.TESTFN
>         self.addCleanup(os_helper.unlink, testfn)
>         with open(testfn, 'w', encoding='utf-8') as f:
>             f.write(textwrap.dedent('''\
>                 import multiprocessing
>                 def f(x): return x*x
>                 if __name__ == '__main__':
>                     with multiprocessing.Pool(200) as p:
>                         print(sum(p.map(f, range(1000))))
>             '''))
>         rc, out, err = script_helper.assert_python_ok(testfn)
>         self.assertEqual("332833500", out.decode('utf-8').strip())
>         self.assertFalse(err, msg=err.decode('utf-8'))
> 
# ----------------------------------------------------------------------
diff Python-3.13.0a4/Modules/_multiprocessing/multiprocessing.c Python-3.13.0a5/Modules/_multiprocessing/multiprocessing.c
184c184
< #if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__)
---
> #if !defined(POSIX_SEMAPHORES_NOT_ENABLED)
diff Python-3.13.0a4/Modules/_multiprocessing/posixshmem.c Python-3.13.0a5/Modules/_multiprocessing/posixshmem.c
4a5
> // Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
6d6
< 
8,9c8
< // Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
< #define Py_LIMITED_API 0x030c0000
---
> #  define Py_LIMITED_API 0x030c0000
13a13
> #include <string.h>               // strlen()
51c51,52
<     const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
---
>     Py_ssize_t name_size;
>     const char *name = PyUnicode_AsUTF8AndSize(path, &name_size);
54a56,59
>     if (strlen(name) != (size_t)name_size) {
>         PyErr_SetString(PyExc_ValueError, "embedded null character");
>         return -1;
>     }
90c95,96
<     const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
---
>     Py_ssize_t name_size;
>     const char *name = PyUnicode_AsUTF8AndSize(path, &name_size);
93a100,103
>     if (strlen(name) != (size_t)name_size) {
>         PyErr_SetString(PyExc_ValueError, "embedded null character");
>         return NULL;
>     }
diff Python-3.13.0a4/Lib/multiprocessing/connection.py Python-3.13.0a5/Lib/multiprocessing/connection.py
478a479
> 
480c481
<         if self._authkey:
---
>         if self._authkey is not None:
diff Python-3.13.0a4/Lib/multiprocessing/queues.py Python-3.13.0a5/Lib/multiprocessing/queues.py
23,24d22
< import _multiprocessing
< 
diff Python-3.13.0a4/Lib/multiprocessing/resource_tracker.py Python-3.13.0a5/Lib/multiprocessing/resource_tracker.py
31a32,34
> def cleanup_noop(name):
>     raise RuntimeError('noop should never be registered or cleaned up')
> 
33c36,37
<     'noop': lambda: None,
---
>     'noop': cleanup_noop,
>     'dummy': lambda name: None,  # Dummy resource used in tests
63a68
>         self._exitcode = None
87c92,93
<             os.waitpid(self._pid, 0)
---
>             _, status = os.waitpid(self._pid, 0)
> 
89a96,101
>             try:
>                 self._exitcode = os.waitstatus_to_exitcode(status)
>             except ValueError:
>                 # os.waitstatus_to_exitcode may raise an exception for invalid values
>                 self._exitcode = None
> 
121a134
>                 self._exitcode = None
223a237,238
>     exit_code = 0
> 
244a260
>                     exit_code = 3
254,257c270,280
<                     warnings.warn(
<                         f'resource_tracker: There appear to be {len(rtype_cache)} '
<                         f'leaked {rtype} objects to clean up at shutdown: {rtype_cache}'
<                     )
---
>                     exit_code = 1
>                     if rtype == 'dummy':
>                         # The test 'dummy' resource is expected to leak.
>                         # We skip the warning (and *only* the warning) for it.
>                         pass
>                     else:
>                         warnings.warn(
>                             f'resource_tracker: There appear to be '
>                             f'{len(rtype_cache)} leaked {rtype} objects to '
>                             f'clean up at shutdown: {rtype_cache}'
>                         )
267a291
>                         exit_code = 2
270a295,296
> 
>         sys.exit(exit_code)
diff Python-3.13.0a4/Lib/multiprocessing/util.py Python-3.13.0a5/Lib/multiprocessing/util.py
105,109c105
<     if sys.platform == "linux":
<         return True
<     if hasattr(sys, 'getandroidapilevel'):
<         return True
<     return False
---
>     return sys.platform in ("linux", "android")
diff Python-3.13.0a4/Lib/test/_test_multiprocessing.py Python-3.13.0a5/Lib/test/_test_multiprocessing.py 
3506a3507,3530
>     def test_empty_authkey(self):
>         # bpo-43952: allow empty bytes as authkey
>         def handler(*args):
>             raise RuntimeError('Connection took too long...')
> 
>         def run(addr, authkey):
>             client = self.connection.Client(addr, authkey=authkey)
>             client.send(1729)
> 
>         key = b''
> 
>         with self.connection.Listener(authkey=key) as listener:
>             thread = threading.Thread(target=run, args=(listener.address, key))
>             thread.start()
>             try:
>                 with listener.accept() as d:
>                     self.assertEqual(d.recv(), 1729)
>             finally:
>                 thread.join()
> 
>         if self.TYPE == 'processes':
>             with self.assertRaises(OSError):
>                 listener.accept()
> 
3973a3998,4012
>     def test_shared_memory_name_with_embedded_null(self):
>         name_tsmb = self._new_shm_name('test01_null')
>         sms = shared_memory.SharedMemory(name_tsmb, create=True, size=512)
>         self.addCleanup(sms.unlink)
>         with self.assertRaises(ValueError):
>             shared_memory.SharedMemory(name_tsmb + '\0a', create=False, size=512)
>         if shared_memory._USE_POSIX:
>             orig_name = sms._name
>             try:
>                 sms._name = orig_name + '\0a'
>                 with self.assertRaises(ValueError):
>                     sms.unlink()
>             finally:
>                 sms._name = orig_name
> 
4108c4147
<     def test_invalid_shared_memory_cration(self):
---
>     def test_invalid_shared_memory_creation(self):
5612c5651
<                 if rtype == "noop":
---
>                 if rtype in ("noop", "dummy"):
5613a5653
>                     # or tests
5732a5773,5804
>     def _test_resource_tracker_leak_resources(self, cleanup):
>         # We use a separate instance for testing, since the main global
>         # _resource_tracker may be used to watch test infrastructure.
>         from multiprocessing.resource_tracker import ResourceTracker
>         tracker = ResourceTracker()
>         tracker.ensure_running()
>         self.assertTrue(tracker._check_alive())
> 
>         self.assertIsNone(tracker._exitcode)
>         tracker.register('somename', 'dummy')
>         if cleanup:
>             tracker.unregister('somename', 'dummy')
>             expected_exit_code = 0
>         else:
>             expected_exit_code = 1
> 
>         self.assertTrue(tracker._check_alive())
>         self.assertIsNone(tracker._exitcode)
>         tracker._stop()
>         self.assertEqual(tracker._exitcode, expected_exit_code)
> 
>     def test_resource_tracker_exit_code(self):
>         """
>         Test the exit code of the resource tracker.
> 
>         If no leaked resources were found, exit code should be 0, otherwise 1
>         """
>         for cleanup in [True, False]:
>             with self.subTest(cleanup=cleanup):
>                 self._test_resource_tracker_leak_resources(
>                     cleanup=cleanup,
>                 )
# ----------------------------------------------------------------------
diff Python-3.13.0a5/Modules/_multiprocessing/semaphore.c Python-3.13.0a6/Modules/_multiprocessing/semaphore.c
83a84
> @critical_section
95c96
< /*[clinic end generated code: output=f9998f0b6b0b0872 input=e5b45f5cbb775166]*/
---
> /*[clinic end generated code: output=f9998f0b6b0b0872 input=079ca779975f3ad6]*/
174a176
> @critical_section
182c184
< /*[clinic end generated code: output=b22f53ba96b0d1db input=ba7e63a961885d3d]*/
---
> /*[clinic end generated code: output=b22f53ba96b0d1db input=9bd62d3645e7a531]*/
299a302
> @critical_section
311c314
< /*[clinic end generated code: output=f9998f0b6b0b0872 input=e5b45f5cbb775166]*/
---
> /*[clinic end generated code: output=f9998f0b6b0b0872 input=079ca779975f3ad6]*/
384a388
> @critical_section
392c396
< /*[clinic end generated code: output=b22f53ba96b0d1db input=ba7e63a961885d3d]*/
---
> /*[clinic end generated code: output=b22f53ba96b0d1db input=9bd62d3645e7a531]*/
585a590
> @critical_section
593c598
< /*[clinic end generated code: output=5ba8213900e517bb input=36fc59b1cd1025ab]*/
---
> /*[clinic end generated code: output=5ba8213900e517bb input=9fa6e0b321b16935]*/
diff Python-3.13.0a5/Lib/test/_test_multiprocessing.py Python-3.13.0a6/Lib/test/_test_multiprocessing.py 
4665c4665
<             sys.setswitchinterval(1e-6)
---
>             support.setswitchinterval(1e-6)
# ----------------------------------------------------------------------
diff Python-3.13.0a6/Modules/_multiprocessing/multiprocessing.c Python-3.13.0b1/Modules/_multiprocessing/multiprocessing.c
279a280
>     {Py_mod_gil, Py_MOD_GIL_NOT_USED},
diff Python-3.13.0a6/Modules/_multiprocessing/posixshmem.c Python-3.13.0b1/Modules/_multiprocessing/posixshmem.c
5c5
< // Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
---
> // Need limited C API version 3.13 for Py_mod_gil
8c8
< #  define Py_LIMITED_API 0x030c0000
---
> #  define Py_LIMITED_API 0x030d0000
130a131
>     {Py_mod_gil, Py_MOD_GIL_NOT_USED},
diff Python-3.13.0a6/Lib/multiprocessing/forkserver.py Python-3.13.0b1/Lib/multiprocessing/forkserver.py
0a1
> import atexit
273a275,276
>                                 atexit._clear()
>                                 atexit.register(util._exit_function)
280a284
>                                 atexit._run_exitfuncs()
diff Python-3.13.0a6/Lib/multiprocessing/popen_fork.py Python-3.13.0b1/Lib/multiprocessing/popen_fork.py
0a1
> import atexit
68a70,71
>                 atexit._clear()
>                 atexit.register(util._exit_function)
72a76
>                 atexit._run_exitfuncs()
diff Python-3.13.0a6/Lib/multiprocessing/popen_spawn_win32.py Python-3.13.0b1/Lib/multiprocessing/popen_spawn_win32.py
5a6
> from subprocess import STARTUPINFO, STARTF_FORCEOFFFEEDBACK
77c78,79
<                     None, None, False, 0, env, None, None)
---
>                     None, None, False, 0, env, None,
>                     STARTUPINFO(dwFlags=STARTF_FORCEOFFFEEDBACK))
diff Python-3.13.0a6/Lib/multiprocessing/process.py Python-3.13.0b1/Lib/multiprocessing/process.py
313,317c313,314
<             try:
<                 self.run()
<                 exitcode = 0
<             finally:
<                 util._exit_function()
---
>             self.run()
>             exitcode = 0
diff Python-3.13.0a6/Lib/test/_test_multiprocessing.py Python-3.13.0b1/Lib/test/_test_multiprocessing.py 
2815d2814
<         gc.collect()  # For PyPy or other GCs.
2816a2816
>         support.gc_collect()  # For PyPy or other GCs.
6163a6164,6186
> class _TestAtExit(BaseTestCase):
> 
>     ALLOWED_TYPES = ('processes',)
> 
>     @classmethod
>     def _write_file_at_exit(self, output_path):
>         import atexit
>         def exit_handler():
>             with open(output_path, 'w') as f:
>                 f.write("deadbeef")
>         atexit.register(exit_handler)
> 
>     def test_atexit(self):
>         # gh-83856
>         with os_helper.temp_dir() as temp_dir:
>             output_path = os.path.join(temp_dir, 'output.txt')
>             p = self.Process(target=self._write_file_at_exit, args=(output_path,))
>             p.start()
>             p.join()
>             with open(output_path) as f:
>                 self.assertEqual(f.read(), 'deadbeef')
> 
> 
# ----------------------------------------------------------------------
diff Python-3.13.0b1/Modules/_multiprocessing Python-3.13.0rc1/Modules/_multiprocessing/
diff Python-3.13.0b1/Modules/_multiprocessing/semaphore.c Python-3.13.0rc1/Modules/_multiprocessing/semaphore.c
684a685
> @critical_section
692c693
< /*[clinic end generated code: output=beeb2f07c858511f input=c5e27d594284690b]*/
---
> /*[clinic end generated code: output=beeb2f07c858511f input=d35c9860992ee790]*/
697a699
> @critical_section
712c714
< /*[clinic end generated code: output=3b37c1a9f8b91a03 input=7d644b64a89903f8]*/
---
> /*[clinic end generated code: output=3b37c1a9f8b91a03 input=1610c8cc3e0e337e]*/
# ----------------------------------------------------------------------
diff Python-3.13.0b1/Modules/_multiprocessing/clinic/ Python-3.13.0rc1/Modules/_multiprocessing/clinic/
diff Python-3.13.0b1/Modules/_multiprocessing/clinic/semaphore.c.h Python-3.13.0rc1/Modules/_multiprocessing/clinic/semaphore.c.h
476c476,482
<     return _multiprocessing_SemLock___enter___impl(self);
---
>     PyObject *return_value = NULL;
> 
>     Py_BEGIN_CRITICAL_SECTION(self);
>     return_value = _multiprocessing_SemLock___enter___impl(self);
>     Py_END_CRITICAL_SECTION();
> 
>     return return_value;
520a527
>     Py_BEGIN_CRITICAL_SECTION(self);
521a529
>     Py_END_CRITICAL_SECTION();
568c576
< /*[clinic end generated code: output=713b597256233716 input=a9049054013a1b77]*/
---
> /*[clinic end generated code: output=dea36482d23a355f input=a9049054013a1b77]*/
# ----------------------------------------------------------------------
diff Python-3.13.0b1/Lib/test/_test_multiprocessing.py Python-3.13.0rc1/Lib/test/_test_multiprocessing.py 
25d24
< import pathlib
327,328c326,328
<             sys.executable.encode(),      # bytes
<             pathlib.Path(sys.executable)  # os.PathLike
---
>             os.fsencode(sys.executable),  # bytes
>             os_helper.FakePath(sys.executable),  # os.PathLike
>             os_helper.FakePath(os.fsencode(sys.executable)),  # os.PathLike bytes
1334a1335,1351
>     def test_closed_queue_empty_exceptions(self):
>         # Assert that checking the emptiness of an unused closed queue
>         # does not raise an OSError. The rationale is that q.close() is
>         # a no-op upon construction and becomes effective once the queue
>         # has been used (e.g., by calling q.put()).
>         for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
>             q.close()  # this is a no-op since the feeder thread is None
>             q.join_thread()  # this is also a no-op
>             self.assertTrue(q.empty())
> 
>         for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
>             q.put('foo')  # make sure that the queue is 'used'
>             q.close()  # close the feeder thread
>             q.join_thread()  # make sure to join the feeder thread
>             with self.assertRaisesRegex(OSError, 'is closed'):
>                 q.empty()
> 
5817a5835,5843
>     def test_empty_exceptions(self):
>         # Assert that checking emptiness of a closed queue raises
>         # an OSError, independently of whether the queue was used
>         # or not. This differs from Queue and JoinableQueue.
>         q = multiprocessing.SimpleQueue()
>         q.close()  # close the pipe
>         with self.assertRaisesRegex(OSError, 'is closed'):
>             q.empty()
> 
# ----------------------------------------------------------------------
diff Python-3.13.0rc1/Lib/multiprocessing/connection.py Python-3.13.1/Lib/multiprocessing/connection.py
959c959
<         raise AuthenticationError('challenge too short: {len(message)} bytes')
---
>         raise AuthenticationError(f'challenge too short: {len(message)} bytes')
diff Python-3.13.0rc1/Lib/multiprocessing/forkserver.py Python-3.13.1/Lib/multiprocessing/forkserver.py
170a171,172
>         if sys_path is not None:
>             sys.path[:] = sys_path
diff Python-3.13.0rc1/Lib/multiprocessing/managers.py Python-3.13.1/Lib/multiprocessing/managers.py
760a761,764
>     # Each instance gets a `_serial` number. Unlike `id(...)`, this number
>     # is never reused.
>     _next_serial = 1
> 
764,767c768,774
<             tls_idset = BaseProxy._address_to_local.get(token.address, None)
<             if tls_idset is None:
<                 tls_idset = util.ForkAwareLocal(), ProcessLocalSet()
<                 BaseProxy._address_to_local[token.address] = tls_idset
---
>             tls_serials = BaseProxy._address_to_local.get(token.address, None)
>             if tls_serials is None:
>                 tls_serials = util.ForkAwareLocal(), ProcessLocalSet()
>                 BaseProxy._address_to_local[token.address] = tls_serials
> 
>             self._serial = BaseProxy._next_serial
>             BaseProxy._next_serial += 1
771c778
<         self._tls = tls_idset[0]
---
>         self._tls = tls_serials[0]
773,774c780,781
<         # self._idset is used to record the identities of all shared
<         # objects for which the current process owns references and
---
>         # self._all_serials is a set used to record the identities of all
>         # shared objects for which the current process owns references and
776c783
<         self._idset = tls_idset[1]
---
>         self._all_serials = tls_serials[1]
859c866
<         self._idset.add(self._id)
---
>         self._all_serials.add(self._serial)
865,866c872,873
<             args=(self._token, self._authkey, state,
<                   self._tls, self._idset, self._Client),
---
>             args=(self._token, self._serial, self._authkey, state,
>                   self._tls, self._all_serials, self._Client),
871,872c878,879
<     def _decref(token, authkey, state, tls, idset, _Client):
<         idset.discard(token.id)
---
>     def _decref(token, serial, authkey, state, tls, idset, _Client):
>         idset.discard(serial)
diff Python-3.13.0rc1/Lib/multiprocessing/synchronize.py Python-3.13.1/Lib/multiprocessing/synchronize.py
177c177
<             elif self._semlock._get_value() == 1:
---
>             elif not self._semlock._is_zero():
203c203
<             elif self._semlock._get_value() == 1:
---
>             elif not self._semlock._is_zero():
diff Python-3.13.0rc1/Lib/test/_test_multiprocessing.py Python-3.13.1/Lib/test/_test_multiprocessing.py 
14a15
> import importlib
21a23
> import shutil
23a26
> import tempfile
256a260,262
>     # If not empty, limit which start method suites run this class.
>     START_METHODS: set[str] = set()
>     start_method = None  # set by install_tests_in_module_dict()
1364a1371,1430
>     @staticmethod
>     def _acquire(lock, l=None):
>         lock.acquire()
>         if l is not None:
>             l.append(repr(lock))
> 
>     @staticmethod
>     def _acquire_event(lock, event):
>         lock.acquire()
>         event.set()
>         time.sleep(1.0)
> 
>     def test_repr_lock(self):
>         if self.TYPE != 'processes':
>             self.skipTest('test not appropriate for {}'.format(self.TYPE))
> 
>         lock = self.Lock()
>         self.assertEqual(f'<Lock(owner=None)>', repr(lock))
> 
>         lock.acquire()
>         self.assertEqual(f'<Lock(owner=MainProcess)>', repr(lock))
>         lock.release()
> 
>         tname = 'T1'
>         l = []
>         t = threading.Thread(target=self._acquire,
>                              args=(lock, l),
>                              name=tname)
>         t.start()
>         time.sleep(0.1)
>         self.assertEqual(f'<Lock(owner=MainProcess|{tname})>', l[0])
>         lock.release()
> 
>         t = threading.Thread(target=self._acquire,
>                              args=(lock,),
>                              name=tname)
>         t.start()
>         time.sleep(0.1)
>         self.assertEqual('<Lock(owner=SomeOtherThread)>', repr(lock))
>         lock.release()
> 
>         pname = 'P1'
>         l = multiprocessing.Manager().list()
>         p = self.Process(target=self._acquire,
>                          args=(lock, l),
>                          name=pname)
>         p.start()
>         p.join()
>         self.assertEqual(f'<Lock(owner={pname})>', l[0])
> 
>         lock = self.Lock()
>         event = self.Event()
>         p = self.Process(target=self._acquire_event,
>                          args=(lock, event),
>                          name='P2')
>         p.start()
>         event.wait()
>         self.assertEqual(f'<Lock(owner=SomeOtherProcess)>', repr(lock))
>         p.terminate()
> 
1371a1438,1499
>     @staticmethod
>     def _acquire_release(lock, timeout, l=None, n=1):
>         for _ in range(n):
>             lock.acquire()
>         if l is not None:
>             l.append(repr(lock))
>         time.sleep(timeout)
>         for _ in range(n):
>             lock.release()
> 
>     def test_repr_rlock(self):
>         if self.TYPE != 'processes':
>             self.skipTest('test not appropriate for {}'.format(self.TYPE))
> 
>         lock = self.RLock()
>         self.assertEqual('<RLock(None, 0)>', repr(lock))
> 
>         n = 3
>         for _ in range(n):
>             lock.acquire()
>         self.assertEqual(f'<RLock(MainProcess, {n})>', repr(lock))
>         for _ in range(n):
>             lock.release()
> 
>         t, l = [], []
>         for i in range(n):
>             t.append(threading.Thread(target=self._acquire_release,
>                                       args=(lock, 0.1, l, i+1),
>                                       name=f'T{i+1}'))
>             t[-1].start()
>         for t_ in t:
>             t_.join()
>         for i in range(n):
>             self.assertIn(f'<RLock(MainProcess|T{i+1}, {i+1})>', l)
> 
> 
>         t = threading.Thread(target=self._acquire_release,
>                                  args=(lock, 0.2),
>                                  name=f'T1')
>         t.start()
>         time.sleep(0.1)
>         self.assertEqual('<RLock(SomeOtherThread, nonzero)>', repr(lock))
>         time.sleep(0.2)
> 
>         pname = 'P1'
>         l = multiprocessing.Manager().list()
>         p = self.Process(target=self._acquire_release,
>                          args=(lock, 0.1, l),
>                          name=pname)
>         p.start()
>         p.join()
>         self.assertEqual(f'<RLock({pname}, 1)>', l[0])
> 
>         event = self.Event()
>         lock = self.RLock()
>         p = self.Process(target=self._acquire_event,
>                          args=(lock, event))
>         p.start()
>         event.wait()
>         self.assertEqual('<RLock(SomeOtherProcess, nonzero)>', repr(lock))
>         p.join()
> 
5749a5878,5879
>     @unittest.skipIf(sys.platform.startswith("netbsd"),
>                      "gh-125620: Skip on NetBSD due to long wait for SIGKILL process termination.")
6212a6343,6412
> class _TestSpawnedSysPath(BaseTestCase):
>     """Test that sys.path is setup in forkserver and spawn processes."""
> 
>     ALLOWED_TYPES = {'processes'}
>     # Not applicable to fork which inherits everything from the process as is.
>     START_METHODS = {"forkserver", "spawn"}
> 
>     def setUp(self):
>         self._orig_sys_path = list(sys.path)
>         self._temp_dir = tempfile.mkdtemp(prefix="test_sys_path-")
>         self._mod_name = "unique_test_mod"
>         module_path = os.path.join(self._temp_dir, f"{self._mod_name}.py")
>         with open(module_path, "w", encoding="utf-8") as mod:
>             mod.write("# A simple test module\n")
>         sys.path[:] = [p for p in sys.path if p]  # remove any existing ""s
>         sys.path.insert(0, self._temp_dir)
>         sys.path.insert(0, "")  # Replaced with an abspath in child.
>         self.assertIn(self.start_method, self.START_METHODS)
>         self._ctx = multiprocessing.get_context(self.start_method)
> 
>     def tearDown(self):
>         sys.path[:] = self._orig_sys_path
>         shutil.rmtree(self._temp_dir, ignore_errors=True)
> 
>     @staticmethod
>     def enq_imported_module_names(queue):
>         queue.put(tuple(sys.modules))
> 
>     def test_forkserver_preload_imports_sys_path(self):
>         if self._ctx.get_start_method() != "forkserver":
>             self.skipTest("forkserver specific test.")
>         self.assertNotIn(self._mod_name, sys.modules)
>         multiprocessing.forkserver._forkserver._stop()  # Must be fresh.
>         self._ctx.set_forkserver_preload(
>             ["test.test_multiprocessing_forkserver", self._mod_name])
>         q = self._ctx.Queue()
>         proc = self._ctx.Process(
>                 target=self.enq_imported_module_names, args=(q,))
>         proc.start()
>         proc.join()
>         child_imported_modules = q.get()
>         q.close()
>         self.assertIn(self._mod_name, child_imported_modules)
> 
>     @staticmethod
>     def enq_sys_path_and_import(queue, mod_name):
>         queue.put(sys.path)
>         try:
>             importlib.import_module(mod_name)
>         except ImportError as exc:
>             queue.put(exc)
>         else:
>             queue.put(None)
> 
>     def test_child_sys_path(self):
>         q = self._ctx.Queue()
>         proc = self._ctx.Process(
>                 target=self.enq_sys_path_and_import, args=(q, self._mod_name))
>         proc.start()
>         proc.join()
>         child_sys_path = q.get()
>         import_error = q.get()
>         q.close()
>         self.assertNotIn("", child_sys_path)  # replaced by an abspath
>         self.assertIn(self._temp_dir, child_sys_path)  # our addition
>         # ignore the first element, it is the absolute "" replacement
>         self.assertEqual(child_sys_path[1:], sys.path[1:])
>         self.assertIsNone(import_error, msg=f"child could not import {self._mod_name}")
> 
> 
6406a6607,6608
>             if base.START_METHODS and start_method not in base.START_METHODS:
>                 continue  # class not intended for this start method.
6419a6622
>                 Temp.start_method = start_method
# ----------------------------------------------------------------------
diff Python-3.13.1/Modules/_multiprocessing/semaphore.c Python-3.13.2/Modules/_multiprocessing/semaphore.c
29a30,31
> #define _SemLockObject_CAST(op) ((SemLockObject *)(op))
> 
578c580
< semlock_dealloc(SemLockObject* self)
---
> semlock_dealloc(PyObject *op)
579a582
>     SemLockObject *self = _SemLockObject_CAST(op);
720c723
< semlock_traverse(SemLockObject *s, visitproc visit, void *arg)
---
> semlock_traverse(PyObject *s, visitproc visit, void *arg)
diff Python-3.13.1/Lib/multiprocessing/connection.py Python-3.13.2/Lib/multiprocessing/connection.py
849c849
< def _get_digest_name_and_payload(message: bytes) -> (str, bytes):
---
> def _get_digest_name_and_payload(message):  # type: (bytes) -> tuple[str, bytes]
diff Python-3.13.1/Lib/multiprocessing/resource_tracker.py Python-3.13.2/Lib/multiprocessing/resource_tracker.py
157a158
>                 prev_sigmask = None
160c161
<                         signal.pthread_sigmask(signal.SIG_BLOCK, _IGNORED_SIGNALS)
---
>                         prev_sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, _IGNORED_SIGNALS)
163,164c164,165
<                     if _HAVE_SIGMASK:
<                         signal.pthread_sigmask(signal.SIG_UNBLOCK, _IGNORED_SIGNALS)
---
>                     if prev_sigmask is not None:
>                         signal.pthread_sigmask(signal.SIG_SETMASK, prev_sigmask)
diff Python-3.13.1/Lib/multiprocessing/synchronize.py Python-3.13.2/Lib/multiprocessing/synchronize.py
363c363
<     def __repr__(self) -> str:
---
>     def __repr__(self):
diff Python-3.13.1/Lib/test/_test_multiprocessing.py Python-3.13.2/Lib/test/_test_multiprocessing.py 
5952a5953,5973
>     @unittest.skipUnless(hasattr(signal, "pthread_sigmask"), "pthread_sigmask is not available")
>     def test_resource_tracker_blocked_signals(self):
>         #
>         # gh-127586: Check that resource_tracker does not override blocked signals of caller.
>         #
>         from multiprocessing.resource_tracker import ResourceTracker
>         orig_sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, set())
>         signals = {signal.SIGTERM, signal.SIGINT, signal.SIGUSR1}
> 
>         try:
>             for sig in signals:
>                 signal.pthread_sigmask(signal.SIG_SETMASK, {sig})
>                 self.assertEqual(signal.pthread_sigmask(signal.SIG_BLOCK, set()), {sig})
>                 tracker = ResourceTracker()
>                 tracker.ensure_running()
>                 self.assertEqual(signal.pthread_sigmask(signal.SIG_BLOCK, set()), {sig})
>                 tracker._stop()
>         finally:
>             # restore sigmask to what it was before executing test
>             signal.pthread_sigmask(signal.SIG_SETMASK, orig_sigmask)
> 
# ----------------------------------------------------------------------
diff Python-3.13.2/Lib/multiprocessing/resource_tracker.py Python-3.13.3/Lib/multiprocessing/resource_tracker.py
78,86c78,94
<     def _stop(self):
<         with self._lock:
<             # This should not happen (_stop() isn't called by a finalizer)
<             # but we check for it anyway.
<             if self._lock._recursion_count() > 1:
<                 return self._reentrant_call_error()
<             if self._fd is None:
<                 # not running
<                 return
---
>     def __del__(self):
>         # making sure child processess are cleaned before ResourceTracker
>         # gets destructed.
>         # see https://github.com/python/cpython/issues/88887
>         self._stop(use_blocking_lock=False)
> 
>     def _stop(self, use_blocking_lock=True):
>         if use_blocking_lock:
>             with self._lock:
>                 self._stop_locked()
>         else:
>             acquired = self._lock.acquire(blocking=False)
>             try:
>                 self._stop_locked()
>             finally:
>                 if acquired:
>                     self._lock.release()
88,90c96,114
<             # closing the "alive" file descriptor stops main()
<             os.close(self._fd)
<             self._fd = None
---
>     def _stop_locked(
>         self,
>         close=os.close,
>         waitpid=os.waitpid,
>         waitstatus_to_exitcode=os.waitstatus_to_exitcode,
>     ):
>         # This shouldn't happen (it might when called by a finalizer)
>         # so we check for it anyway.
>         if self._lock._recursion_count() > 1:
>             return self._reentrant_call_error()
>         if self._fd is None:
>             # not running
>             return
>         if self._pid is None:
>             return
> 
>         # closing the "alive" file descriptor stops main()
>         close(self._fd)
>         self._fd = None
92c116
<             _, status = os.waitpid(self._pid, 0)
---
>         _, status = waitpid(self._pid, 0)
94c118
<             self._pid = None
---
>         self._pid = None
96,100c120,124
<             try:
<                 self._exitcode = os.waitstatus_to_exitcode(status)
<             except ValueError:
<                 # os.waitstatus_to_exitcode may raise an exception for invalid values
<                 self._exitcode = None
---
>         try:
>             self._exitcode = waitstatus_to_exitcode(status)
>         except ValueError:
>             # os.waitstatus_to_exitcode may raise an exception for invalid values
>             self._exitcode = None
diff Python-3.13.2/Lib/test/_test_multiprocessing.py Python-3.13.3/Lib/test/_test_multiprocessing.py 
591c591,592
<         p = self.Process(target=time.sleep, args=(DELTA,))
---
>         event = self.Event()
>         p = self.Process(target=event.wait, args=())
594,596c595,600
<         p.daemon = True
<         p.start()
<         self.assertIn(p, self.active_children())
---
>         try:
>             p.daemon = True
>             p.start()
>             self.assertIn(p, self.active_children())
>         finally:
>             event.set()
1580c1584
<         for i in range(10):
---
>         for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
1586,1587c1590
<             time.sleep(DELTA)
<         time.sleep(DELTA)
---
> 
1609d1611
<         self.addCleanup(p.join)
1611,1614c1613,1615
<         p = threading.Thread(target=self.f, args=(cond, sleeping, woken))
<         p.daemon = True
<         p.start()
<         self.addCleanup(p.join)
---
>         t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
>         t.daemon = True
>         t.start()
1621,1622c1622
<         time.sleep(DELTA)
<         self.assertReturnsIfImplemented(0, get_value, woken)
---
>         self.assertReachesEventually(lambda: get_value(woken), 0)
1630,1631c1630
<         time.sleep(DELTA)
<         self.assertReturnsIfImplemented(1, get_value, woken)
---
>         self.assertReachesEventually(lambda: get_value(woken), 1)
1639,1640c1638
<         time.sleep(DELTA)
<         self.assertReturnsIfImplemented(2, get_value, woken)
---
>         self.assertReachesEventually(lambda: get_value(woken), 2)
1644c1642,1644
<         p.join()
---
> 
>         threading_helper.join_thread(t)
>         join_process(p)
1651a1652
>         workers = []
1657c1658
<             self.addCleanup(p.join)
---
>             workers.append(p)
1663c1664
<             self.addCleanup(t.join)
---
>             workers.append(t)
1682c1683
<             self.addCleanup(p.join)
---
>             workers.append(p)
1687c1688
<             self.addCleanup(t.join)
---
>             workers.append(t)
1703c1704,1706
<         self.assertReachesEventually(lambda: get_value(woken), 6)
---
>         for i in range(6):
>             woken.acquire()
>         self.assertReturnsIfImplemented(0, get_value, woken)
1707a1711,1714
>         for w in workers:
>             # NOTE: join_process and join_thread are the same
>             threading_helper.join_thread(w)
> 
1713a1721
>         workers = []
1718c1726
<             self.addCleanup(p.join)
---
>             workers.append(p)
1723c1731
<             self.addCleanup(t.join)
---
>             workers.append(t)
1757a1766,1769
>         for w in workers:
>             # NOTE: join_process and join_thread are the same
>             threading_helper.join_thread(w)
> 
# ----------------------------------------------------------------------
diff Python-3.13.3/Lib/multiprocessing/context.py Python-3.13.4/Lib/multiprocessing/context.py
148c148
<         if sys.platform == 'win32' and getattr(sys, 'frozen', False):
---
>         if self.get_start_method() == 'spawn' and getattr(sys, 'frozen', False):
diff Python-3.13.3/Lib/test/_test_multiprocessing.py Python-3.13.4/Lib/test/_test_multiprocessing.py 
514a515,519
>     def _sleep_some_event(cls, event):
>         event.set()
>         time.sleep(100)
> 
>     @classmethod
522c527,528
<         p = self.Process(target=self._sleep_some)
---
>         event = self.Event()
>         p = self.Process(target=self._sleep_some_event, args=(event,))
540,541c546,550
<         # XXX maybe terminating too soon causes the problems on Gentoo...
<         time.sleep(1)
---
>         timeout = support.SHORT_TIMEOUT
>         if not event.wait(timeout):
>             p.terminate()
>             p.join()
>             self.fail(f"event not signaled in {timeout} seconds")
6487a6497,6518
>     def test_forked_thread_not_started(self):
>         # gh-134381: Ensure that a thread that has not been started yet in
>         # the parent process can be started within a forked child process.
> 
>         if multiprocessing.get_start_method() != "fork":
>             self.skipTest("fork specific test")
> 
>         q = multiprocessing.Queue()
>         t = threading.Thread(target=lambda: q.put("done"), daemon=True)
> 
>         def child():
>             t.start()
>             t.join()
> 
>         p = multiprocessing.Process(target=child)
>         p.start()
>         p.join(support.SHORT_TIMEOUT)
> 
>         self.assertEqual(p.exitcode, 0)
>         self.assertEqual(q.get_nowait(), "done")
>         close_queue(q)
> 
# ----------------------------------------------------------------------
diff Python-3.13.4/Lib/multiprocessing/connection.py Python-3.13.6/Lib/multiprocessing/connection.py
77c77
<         return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir())
---
>         return tempfile.mktemp(prefix='sock-', dir=util.get_temp_dir())
diff Python-3.13.4/Lib/multiprocessing/forkserver.py Python-3.13.6/Lib/multiprocessing/forkserver.py
184a185,188
>         # gh-135335: flush stdout/stderr in case any of the preloaded modules
>         # wrote to them, otherwise children might inherit buffered data
>         util._flush_std_streams()
> 
diff Python-3.13.4/Lib/multiprocessing/util.py Python-3.13.6/Lib/multiprocessing/util.py
36a37
> WARNING = 30
55a57,60
> def _warn(msg, *args):
>     if _logger:
>         _logger.log(WARNING, msg, *args, stacklevel=2)
> 
123a129,143
> # Maximum length of a socket file path is usually between 92 and 108 [1],
> # but Linux is known to use a size of 108 [2]. BSD-based systems usually
> # use a size of 104 or 108 and Windows does not create AF_UNIX sockets.
> #
> # [1]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html
> # [2]: https://man7.org/linux/man-pages/man7/unix.7.html.
> 
> if sys.platform == 'linux':
>     _SUN_PATH_MAX = 108
> elif sys.platform.startswith(('openbsd', 'freebsd')):
>     _SUN_PATH_MAX = 104
> else:
>     # On Windows platforms, we do not create AF_UNIX sockets.
>     _SUN_PATH_MAX = None if os.name == 'nt' else 92
> 
132a153,206
> def _get_base_temp_dir(tempfile):
>     """Get a temporary directory where socket files will be created.
> 
>     To prevent additional imports, pass a pre-imported 'tempfile' module.
>     """
>     if os.name == 'nt':
>         return None
>     # Most of the time, the default temporary directory is /tmp. Thus,
>     # listener sockets files "$TMPDIR/pymp-XXXXXXXX/sock-XXXXXXXX" do
>     # not have a path length exceeding SUN_PATH_MAX.
>     #
>     # If users specify their own temporary directory, we may be unable
>     # to create those files. Therefore, we fall back to the system-wide
>     # temporary directory /tmp, assumed to exist on POSIX systems.
>     #
>     # See https://github.com/python/cpython/issues/132124.
>     base_tempdir = tempfile.gettempdir()
>     # Files created in a temporary directory are suffixed by a string
>     # generated by tempfile._RandomNameSequence, which, by design,
>     # is 8 characters long.
>     #
>     # Thus, the length of socket filename will be:
>     #
>     #   len(base_tempdir + '/pymp-XXXXXXXX' + '/sock-XXXXXXXX')
>     sun_path_len = len(base_tempdir) + 14 + 14
>     if sun_path_len <= _SUN_PATH_MAX:
>         return base_tempdir
>     # Fallback to the default system-wide temporary directory.
>     # This ignores user-defined environment variables.
>     #
>     # On POSIX systems, /tmp MUST be writable by any application [1].
>     # We however emit a warning if this is not the case to prevent
>     # obscure errors later in the execution.
>     #
>     # On some legacy systems, /var/tmp and /usr/tmp can be present
>     # and will be used instead.
>     #
>     # [1]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html
>     dirlist = ['/tmp', '/var/tmp', '/usr/tmp']
>     try:
>         base_system_tempdir = tempfile._get_default_tempdir(dirlist)
>     except FileNotFoundError:
>         _warn("Process-wide temporary directory %s will not be usable for "
>               "creating socket files and no usable system-wide temporary "
>               "directory was found in %s", base_tempdir, dirlist)
>         # At this point, the system-wide temporary directory is not usable
>         # but we may assume that the user-defined one is, even if we will
>         # not be able to write socket files out there.
>         return base_tempdir
>     _warn("Ignoring user-defined temporary directory: %s", base_tempdir)
>     # at most max(map(len, dirlist)) + 14 + 14 = 36 characters
>     assert len(base_system_tempdir) + 14 + 14 <= _SUN_PATH_MAX
>     return base_system_tempdir
> 
138c212,213
<         tempdir = tempfile.mkdtemp(prefix='pymp-')
---
>         base_tempdir = _get_base_temp_dir(tempfile)
>         tempdir = tempfile.mkdtemp(prefix='pymp-', dir=base_tempdir)
diff Python-3.13.4/Lib/test/_test_multiprocessing.py Python-3.13.6/Lib/test/_test_multiprocessing.py 
6453a6454,6482
>     def test_std_streams_flushed_after_preload(self):
>         # gh-135335: Check fork server flushes standard streams after
>         # preloading modules
>         if multiprocessing.get_start_method() != "forkserver":
>             self.skipTest("forkserver specific test")
> 
>         # Create a test module in the temporary directory on the child's path
>         # TODO: This can all be simplified once gh-126631 is fixed and we can
>         #       use __main__ instead of a module.
>         dirname = os.path.join(self._temp_dir, 'preloaded_module')
>         init_name = os.path.join(dirname, '__init__.py')
>         os.mkdir(dirname)
>         with open(init_name, "w") as f:
>             cmd = '''if 1:
>                 import sys
>                 print('stderr', end='', file=sys.stderr)
>                 print('stdout', end='', file=sys.stdout)
>             '''
>             f.write(cmd)
> 
>         name = os.path.join(os.path.dirname(__file__), 'mp_preload_flush.py')
>         env = {'PYTHONPATH': self._temp_dir}
>         _, out, err = test.support.script_helper.assert_python_ok(name, **env)
> 
>         # Check stderr first, as it is more likely to be useful to see in the
>         # event of a failure.
>         self.assertEqual(err.decode().rstrip(), 'stderr')
>         self.assertEqual(out.decode().rstrip(), 'stdout')
> 
# ----------------------------------------------------------------------
diff Python-3.13.6/Lib/multiprocessing/resource_tracker.py Python-3.13.7/Lib/multiprocessing/resource_tracker.py
22a23
> from collections import deque
68a70
>         self._reentrant_messages = deque()
105c107
<             return self._reentrant_call_error()
---
>             raise self._reentrant_call_error()
134a137,198
>         return self._ensure_running_and_write()
> 
>     def _teardown_dead_process(self):
>         os.close(self._fd)
> 
>         # Clean-up to avoid dangling processes.
>         try:
>             # _pid can be None if this process is a child from another
>             # python process, which has started the resource_tracker.
>             if self._pid is not None:
>                 os.waitpid(self._pid, 0)
>         except ChildProcessError:
>             # The resource_tracker has already been terminated.
>             pass
>         self._fd = None
>         self._pid = None
>         self._exitcode = None
> 
>         warnings.warn('resource_tracker: process died unexpectedly, '
>                       'relaunching.  Some resources might leak.')
> 
>     def _launch(self):
>         fds_to_pass = []
>         try:
>             fds_to_pass.append(sys.stderr.fileno())
>         except Exception:
>             pass
>         r, w = os.pipe()
>         try:
>             fds_to_pass.append(r)
>             # process will out live us, so no need to wait on pid
>             exe = spawn.get_executable()
>             args = [
>                 exe,
>                 *util._args_from_interpreter_flags(),
>                 '-c',
>                 f'from multiprocessing.resource_tracker import main;main({r})',
>             ]
>             # bpo-33613: Register a signal mask that will block the signals.
>             # This signal mask will be inherited by the child that is going
>             # to be spawned and will protect the child from a race condition
>             # that can make the child die before it registers signal handlers
>             # for SIGINT and SIGTERM. The mask is unregistered after spawning
>             # the child.
>             prev_sigmask = None
>             try:
>                 if _HAVE_SIGMASK:
>                     prev_sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, _IGNORED_SIGNALS)
>                 pid = util.spawnv_passfds(exe, args, fds_to_pass)
>             finally:
>                 if prev_sigmask is not None:
>                     signal.pthread_sigmask(signal.SIG_SETMASK, prev_sigmask)
>         except:
>             os.close(w)
>             raise
>         else:
>             self._fd = w
>             self._pid = pid
>         finally:
>             os.close(r)
> 
>     def _ensure_running_and_write(self, msg=None):
138c202,205
<                 return self._reentrant_call_error()
---
>                 if msg is None:
>                     raise self._reentrant_call_error()
>                 return self._reentrant_messages.append(msg)
> 
141,147c208,211
<                 if self._check_alive():
<                     # => still alive
<                     return
<                 # => dead, launch it again
<                 os.close(self._fd)
< 
<                 # Clean-up to avoid dangling processes.
---
>                 if msg is None:
>                     to_send = b'PROBE:0:noop\n'
>                 else:
>                     to_send = msg
149,158c213,216
<                     # _pid can be None if this process is a child from another
<                     # python process, which has started the resource_tracker.
<                     if self._pid is not None:
<                         os.waitpid(self._pid, 0)
<                 except ChildProcessError:
<                     # The resource_tracker has already been terminated.
<                     pass
<                 self._fd = None
<                 self._pid = None
<                 self._exitcode = None
---
>                     self._write(to_send)
>                 except OSError:
>                     self._teardown_dead_process()
>                     self._launch()
160,161c218,220
<                 warnings.warn('resource_tracker: process died unexpectedly, '
<                               'relaunching.  Some resources might leak.')
---
>                 msg = None  # message was sent in probe
>             else:
>                 self._launch()
163c222
<             fds_to_pass = []
---
>         while True:
165,197c224,229
<                 fds_to_pass.append(sys.stderr.fileno())
<             except Exception:
<                 pass
<             cmd = 'from multiprocessing.resource_tracker import main;main(%d)'
<             r, w = os.pipe()
<             try:
<                 fds_to_pass.append(r)
<                 # process will out live us, so no need to wait on pid
<                 exe = spawn.get_executable()
<                 args = [exe] + util._args_from_interpreter_flags()
<                 args += ['-c', cmd % r]
<                 # bpo-33613: Register a signal mask that will block the signals.
<                 # This signal mask will be inherited by the child that is going
<                 # to be spawned and will protect the child from a race condition
<                 # that can make the child die before it registers signal handlers
<                 # for SIGINT and SIGTERM. The mask is unregistered after spawning
<                 # the child.
<                 prev_sigmask = None
<                 try:
<                     if _HAVE_SIGMASK:
<                         prev_sigmask = signal.pthread_sigmask(signal.SIG_BLOCK, _IGNORED_SIGNALS)
<                     pid = util.spawnv_passfds(exe, args, fds_to_pass)
<                 finally:
<                     if prev_sigmask is not None:
<                         signal.pthread_sigmask(signal.SIG_SETMASK, prev_sigmask)
<             except:
<                 os.close(w)
<                 raise
<             else:
<                 self._fd = w
<                 self._pid = pid
<             finally:
<                 os.close(r)
---
>                 reentrant_msg = self._reentrant_messages.popleft()
>             except IndexError:
>                 break
>             self._write(reentrant_msg)
>         if msg is not None:
>             self._write(msg)
217a250,253
>     def _write(self, msg):
>         nbytes = os.write(self._fd, msg)
>         assert nbytes == len(msg), f"{nbytes=} != {len(msg)=}"
> 
219,230c255
<         try:
<             self.ensure_running()
<         except ReentrantCallError:
<             # The code below might or might not work, depending on whether
<             # the resource tracker was already running and still alive.
<             # Better warn the user.
<             # (XXX is warnings.warn itself reentrant-safe? :-)
<             warnings.warn(
<                 f"ResourceTracker called reentrantly for resource cleanup, "
<                 f"which is unsupported. "
<                 f"The {rtype} object {name!r} might leak.")
<         msg = '{0}:{1}:{2}\n'.format(cmd, name, rtype).encode('ascii')
---
>         msg = f"{cmd}:{name}:{rtype}\n".encode("ascii")
235,237d259
<         nbytes = os.write(self._fd, msg)
<         assert nbytes == len(msg), "nbytes {0:n} but len(msg) {1:n}".format(
<             nbytes, len(msg))
238a261
>         self._ensure_running_and_write(msg)
# ----------------------------------------------------------------------
diff Python-3.13.7/Lib/multiprocessing/forkserver.py Python-3.13.8/Lib/multiprocessing/forkserver.py
129a130
>             main_kws = {}
131d131
<                 desired_keys = {'main_path', 'sys_path'}
133,135c133,136
<                 data = {x: y for x, y in data.items() if x in desired_keys}
<             else:
<                 data = {}
---
>                 if 'sys_path' in data:
>                     main_kws['sys_path'] = data['sys_path']
>                 if 'init_main_from_path' in data:
>                     main_kws['main_path'] = data['init_main_from_path']
150c151
<                             data)
---
>                             main_kws)
diff Python-3.13.7/Lib/multiprocessing/popen_spawn_posix.py Python-3.13.8/Lib/multiprocessing/popen_spawn_posix.py
59a60,63
>             os.close(child_r)
>             child_r = None
>             os.close(child_w)
>             child_w = None
diff Python-3.13.7/Lib/test/_test_multiprocessing.py Python-3.13.8/Lib/test/_test_multiprocessing.py 
6547a6548,6559
>     def test_preload_main(self):
>         # gh-126631: Check that __main__ can be pre-loaded
>         if multiprocessing.get_start_method() != "forkserver":
>             self.skipTest("forkserver specific test")
> 
>         name = os.path.join(os.path.dirname(__file__), 'mp_preload_main.py')
>         _, out, err = test.support.script_helper.assert_python_ok(name)
>         self.assertEqual(err, b'')
> 
>         # The trailing empty string comes from split() on output ending with \n
>         out = out.decode().split("\n")
>         self.assertEqual(out, ['__main__', '__mp_main__', 'f', 'f', ''])
# ----------------------------------------------------------------------
diff Python-3.13.8/Lib/multiprocessing/resource_tracker.py Python-3.13.10/Lib/multiprocessing/resource_tracker.py
17a18
> import base64
24a26,27
> import json
> 
118c121,126
<         _, status = waitpid(self._pid, 0)
---
>         try:
>             _, status = waitpid(self._pid, 0)
>         except ChildProcessError:
>             self._pid = None
>             self._exitcode = None
>             return
197a206,216
>     def _make_probe_message(self):
>         """Return a JSON-encoded probe message."""
>         return (
>             json.dumps(
>                 {"cmd": "PROBE", "rtype": "noop"},
>                 ensure_ascii=True,
>                 separators=(",", ":"),
>             )
>             + "\n"
>         ).encode("ascii")
> 
209c228
<                     to_send = b'PROBE:0:noop\n'
---
>                     to_send = self._make_probe_message()
236c255
<             os.write(self._fd, b'PROBE:0:noop\n')
---
>             os.write(self._fd, self._make_probe_message())
255,259c274,292
<         msg = f"{cmd}:{name}:{rtype}\n".encode("ascii")
<         if len(msg) > 512:
<             # posix guarantees that writes to a pipe of less than PIPE_BUF
<             # bytes are atomic, and that PIPE_BUF >= 512
<             raise ValueError('msg too long')
---
>         # POSIX guarantees that writes to a pipe of less than PIPE_BUF (512 on Linux)
>         # bytes are atomic. Therefore, we want the message to be shorter than 512 bytes.
>         # POSIX shm_open() and sem_open() require the name, including its leading slash,
>         # to be at most NAME_MAX bytes (255 on Linux)
>         # With json.dump(..., ensure_ascii=True) every non-ASCII byte becomes a 6-char
>         # escape like \uDC80.
>         # As we want the overall message to be kept atomic and therefore smaller than 512,
>         # we encode encode the raw name bytes with URL-safe Base64 - so a 255 long name
>         # will not exceed 340 bytes.
>         b = name.encode('utf-8', 'surrogateescape')
>         if len(b) > 255:
>             raise ValueError('shared memory name too long (max 255 bytes)')
>         b64 = base64.urlsafe_b64encode(b).decode('ascii')
> 
>         payload = {"cmd": cmd, "rtype": rtype, "base64_name": b64}
>         msg = (json.dumps(payload, ensure_ascii=True, separators=(",", ":")) + "\n").encode("ascii")
> 
>         # The entire JSON message is guaranteed < PIPE_BUF (512 bytes) by construction.
>         assert len(msg) <= 512, f"internal error: message too long ({len(msg)} bytes)"
292c325,341
<                     cmd, name, rtype = line.strip().decode('ascii').split(':')
---
>                     try:
>                         obj = json.loads(line.decode('ascii'))
>                     except Exception as e:
>                         raise ValueError("malformed resource_tracker message: %r" % (line,)) from e
> 
>                     cmd = obj["cmd"]
>                     rtype = obj["rtype"]
>                     b64  = obj.get("base64_name", "")
> 
>                     if not isinstance(cmd, str) or not isinstance(rtype, str) or not isinstance(b64, str):
>                         raise ValueError("malformed resource_tracker fields: %r" % (obj,))
> 
>                     try:
>                         name = base64.urlsafe_b64decode(b64).decode('utf-8', 'surrogateescape')
>                     except ValueError as e:
>                         raise ValueError("malformed resource_tracker base64_name: %r" % (b64,)) from e
> 
diff Python-3.13.8/Lib/multiprocessing/util.py Python-3.13.10/Lib/multiprocessing/util.py
129,134c129,136
< # Maximum length of a socket file path is usually between 92 and 108 [1],
< # but Linux is known to use a size of 108 [2]. BSD-based systems usually
< # use a size of 104 or 108 and Windows does not create AF_UNIX sockets.
< #
< # [1]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html
< # [2]: https://man7.org/linux/man-pages/man7/unix.7.html.
---
> # Maximum length of a NULL-terminated [1] socket file path is usually
> # between 92 and 108 [2], but Linux is known to use a size of 108 [3].
> # BSD-based systems usually use a size of 104 or 108 and Windows does
> # not create AF_UNIX sockets.
> #
> # [1]: https://github.com/python/cpython/issues/140734
> # [2]: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html
> # [3]: https://man7.org/linux/man-pages/man7/unix.7.html
174c176
<     # Thus, the length of socket filename will be:
---
>     # Thus, the socket file path length (without NULL terminator) will be:
178c180,182
<     if sun_path_len <= _SUN_PATH_MAX:
---
>     # Strict inequality to account for the NULL terminator.
>     # See https://github.com/python/cpython/issues/140734.
>     if sun_path_len < _SUN_PATH_MAX:
204c208
<     assert len(base_system_tempdir) + 14 + 14 <= _SUN_PATH_MAX
---
>     assert len(base_system_tempdir) + 14 + 14 < _SUN_PATH_MAX
diff Python-3.13.8/Lib/test/_test_multiprocessing.py Python-3.13.10/Lib/test/_test_multiprocessing.py 
1112c1112
<         #queue.put(1)
---
>         queue.put(1)
1136c1136,1138
<         time.sleep(DELTA)
---
>         for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
>             if not queue_empty(queue):
>                 break
1139,1140c1141
<         # Hangs unexpectedly, remove for now
<         #self.assertEqual(queue.get(), 1)
---
>         self.assertEqual(queue.get_nowait(), 1)
1144c1145
<         self.assertEqual(queue.get_nowait(), 5)
---
>         self.assertEqual(queue.get(), 5)
6460,6473d6460
<         # Create a test module in the temporary directory on the child's path
<         # TODO: This can all be simplified once gh-126631 is fixed and we can
<         #       use __main__ instead of a module.
<         dirname = os.path.join(self._temp_dir, 'preloaded_module')
<         init_name = os.path.join(dirname, '__init__.py')
<         os.mkdir(dirname)
<         with open(init_name, "w") as f:
<             cmd = '''if 1:
<                 import sys
<                 print('stderr', end='', file=sys.stderr)
<                 print('stdout', end='', file=sys.stdout)
<             '''
<             f.write(cmd)
< 
6475,6476c6462
<         env = {'PYTHONPATH': self._temp_dir}
<         _, out, err = test.support.script_helper.assert_python_ok(name, **env)
---
>         _, out, err = test.support.script_helper.assert_python_ok(name)
6480,6481c6466,6467
<         self.assertEqual(err.decode().rstrip(), 'stderr')
<         self.assertEqual(out.decode().rstrip(), 'stdout')
---
>         self.assertEqual(err.decode().rstrip(), '__main____mp_main__')
>         self.assertEqual(out.decode().rstrip(), '__main____mp_main__')
6806a6793,6836
> 
> 
> @unittest.skipUnless(HAS_SHMEM, "requires multiprocessing.shared_memory")
> class TestSharedMemoryNames(unittest.TestCase):
>     def test_that_shared_memory_name_with_colons_has_no_resource_tracker_errors(self):
>         # Test script that creates and cleans up shared memory with colon in name
>         test_script = textwrap.dedent("""
>             import sys
>             from multiprocessing import shared_memory
>             import time
> 
>             # Test various patterns of colons in names
>             test_names = [
>                 "a:b",
>                 "a:b:c",
>                 "test:name:with:many:colons",
>                 ":starts:with:colon",
>                 "ends:with:colon:",
>                 "::double::colons::",
>                 "name\\nwithnewline",
>                 "name-with-trailing-newline\\n",
>                 "\\nname-starts-with-newline",
>                 "colons:and\\nnewlines:mix",
>                 "multi\\nline\\nname",
>             ]
> 
>             for name in test_names:
>                 try:
>                     shm = shared_memory.SharedMemory(create=True, size=100, name=name)
>                     shm.buf[:5] = b'hello'  # Write something to the shared memory
>                     shm.close()
>                     shm.unlink()
> 
>                 except Exception as e:
>                     print(f"Error with name '{name}': {e}", file=sys.stderr)
>                     sys.exit(1)
> 
>             print("SUCCESS")
>         """)
> 
>         rc, out, err = script_helper.assert_python_ok("-c", test_script)
>         self.assertIn(b"SUCCESS", out)
>         self.assertNotIn(b"traceback", err.lower(), err)
>         self.assertNotIn(b"resource_tracker.py", err, err)
diff Python-3.13.8/Lib/test/mp_preload_flush.py Python-3.13.10/Lib/test/mp_preload_flush.py 
4c4,5
< modname = 'preloaded_module'
---
> print(__name__, end='', file=sys.stderr)
> print(__name__, end='', file=sys.stdout)
6,7d6
<     if modname in sys.modules:
<         raise AssertionError(f'{modname!r} is not in sys.modules')
9d7
<     multiprocessing.set_forkserver_preload([modname])
14,15d11
< elif modname not in sys.modules:
<     raise AssertionError(f'{modname!r} is not in sys.modules')
# ----------------------------------------------------------------------
diff Python-3.13.10/Lib/multiprocessing/resource_tracker.py Python-3.13.11/Lib/multiprocessing/resource_tracker.py
74a75,81
>         # True to use colon-separated lines, rather than JSON lines,
>         # for internal communication. (Mainly for testing).
>         # Filenames not supported by the simple format will always be sent
>         # using JSON.
>         # The reader should understand all formats.
>         self._use_simple_format = True
> 
207c214,216
<         """Return a JSON-encoded probe message."""
---
>         """Return a probe message."""
>         if self._use_simple_format:
>             return b'PROBE:0:noop\n'
273a283,291
>         if self._use_simple_format and '\n' not in name:
>             msg = f"{cmd}:{name}:{rtype}\n".encode("ascii")
>             if len(msg) > 512:
>                 # posix guarantees that writes to a pipe of less than PIPE_BUF
>                 # bytes are atomic, and that PIPE_BUF >= 512
>                 raise ValueError('msg too long')
>             self._ensure_running_and_write(msg)
>             return
> 
292a311
>         assert msg.startswith(b'{')
302a322,345
> def _decode_message(line):
>     if line.startswith(b'{'):
>         try:
>             obj = json.loads(line.decode('ascii'))
>         except Exception as e:
>             raise ValueError("malformed resource_tracker message: %r" % (line,)) from e
> 
>         cmd = obj["cmd"]
>         rtype = obj["rtype"]
>         b64  = obj.get("base64_name", "")
> 
>         if not isinstance(cmd, str) or not isinstance(rtype, str) or not isinstance(b64, str):
>             raise ValueError("malformed resource_tracker fields: %r" % (obj,))
> 
>         try:
>             name = base64.urlsafe_b64decode(b64).decode('utf-8', 'surrogateescape')
>         except ValueError as e:
>             raise ValueError("malformed resource_tracker base64_name: %r" % (b64,)) from e
>     else:
>         cmd, rest = line.strip().decode('ascii').split(':', maxsplit=1)
>         name, rtype = rest.rsplit(':', maxsplit=1)
>     return cmd, rtype, name
> 
> 
325,341c368
<                     try:
<                         obj = json.loads(line.decode('ascii'))
<                     except Exception as e:
<                         raise ValueError("malformed resource_tracker message: %r" % (line,)) from e
< 
<                     cmd = obj["cmd"]
<                     rtype = obj["rtype"]
<                     b64  = obj.get("base64_name", "")
< 
<                     if not isinstance(cmd, str) or not isinstance(rtype, str) or not isinstance(b64, str):
<                         raise ValueError("malformed resource_tracker fields: %r" % (obj,))
< 
<                     try:
<                         name = base64.urlsafe_b64decode(b64).decode('utf-8', 'surrogateescape')
<                     except ValueError as e:
<                         raise ValueError("malformed resource_tracker base64_name: %r" % (b64,)) from e
< 
---
>                     cmd, rtype, name = _decode_message(line)
diff Python-3.13.10/Lib/test/_test_multiprocessing.py Python-3.13.11/Lib/test/_test_multiprocessing.py 
41c41
< 
---
> from test.support import subTests
4143a4144,4156
> def resource_tracker_format_subtests(func):
>     """Run given test using both resource tracker communication formats"""
>     def _inner(self, *args, **kwargs):
>         tracker = resource_tracker._resource_tracker
>         for use_simple_format in False, True:
>             with (
>                 self.subTest(use_simple_format=use_simple_format),
>                 unittest.mock.patch.object(
>                     tracker, '_use_simple_format', use_simple_format)
>             ):
>                 func(self, *args, **kwargs)
>     return _inner
> 
4420a4434
>     @resource_tracker_format_subtests
4670a4685
>     @resource_tracker_format_subtests
4697a4713
>     @resource_tracker_format_subtests
6797c6813,6815
<     def test_that_shared_memory_name_with_colons_has_no_resource_tracker_errors(self):
---
>     @subTests('use_simple_format', (True, False))
>     def test_that_shared_memory_name_with_colons_has_no_resource_tracker_errors(
>             self, use_simple_format):
6801a6820
>             from multiprocessing import resource_tracker
6803a6823,6824
>             resource_tracker._resource_tracker._use_simple_format = %s
> 
6831c6852
<         """)
---
>         """ % use_simple_format)