Commit 678c422
committed
pythongh-103911: Add exec_timeout parameter to subprocess.Popen
Add a new exec_timeout parameter to subprocess.Popen (POSIX only) that allows
setting a timeout for the child process to execute (exec() to succeed). This
addresses the issue where Popen can hang indefinitely while waiting for the
child process errpipe_read, which can happen when exec() is delayed by
ptrace tools, high-latency filesystems, or other system-level interference.
The implementation uses the selectors module with non-blocking I/O on
errpipe_read to wait for data with a timeout. If the timeout expires,
TimeoutExpired is raised and the child process is killed with SIGKILL.
https://claude.ai/code/session_01Bn3z7ZV4zehn77WPEZ9kuL1 parent 7ca9e7a commit 678c422
3 files changed
Lines changed: 88 additions & 9 deletions
File tree
- Lib
- test
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
810 | 816 | | |
811 | 817 | | |
812 | 818 | | |
| |||
820 | 826 | | |
821 | 827 | | |
822 | 828 | | |
823 | | - | |
| 829 | + | |
824 | 830 | | |
825 | 831 | | |
826 | 832 | | |
| |||
866 | 872 | | |
867 | 873 | | |
868 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
869 | 885 | | |
870 | 886 | | |
871 | 887 | | |
| |||
1042 | 1058 | | |
1043 | 1059 | | |
1044 | 1060 | | |
1045 | | - | |
| 1061 | + | |
| 1062 | + | |
1046 | 1063 | | |
1047 | 1064 | | |
1048 | 1065 | | |
| |||
1455 | 1472 | | |
1456 | 1473 | | |
1457 | 1474 | | |
1458 | | - | |
| 1475 | + | |
| 1476 | + | |
1459 | 1477 | | |
1460 | 1478 | | |
1461 | 1479 | | |
| |||
1829 | 1847 | | |
1830 | 1848 | | |
1831 | 1849 | | |
1832 | | - | |
| 1850 | + | |
| 1851 | + | |
1833 | 1852 | | |
1834 | 1853 | | |
1835 | 1854 | | |
| |||
1937 | 1956 | | |
1938 | 1957 | | |
1939 | 1958 | | |
1940 | | - | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
1944 | | - | |
| 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 | + | |
1945 | 1989 | | |
1946 | 1990 | | |
1947 | 1991 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3628 | 3628 | | |
3629 | 3629 | | |
3630 | 3630 | | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
3631 | 3653 | | |
3632 | 3654 | | |
3633 | 3655 | | |
| |||
3883 | 3905 | | |
3884 | 3906 | | |
3885 | 3907 | | |
| 3908 | + | |
| 3909 | + | |
| 3910 | + | |
| 3911 | + | |
| 3912 | + | |
| 3913 | + | |
| 3914 | + | |
| 3915 | + | |
3886 | 3916 | | |
3887 | 3917 | | |
3888 | 3918 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments