classification
Title: Start the deprecation cycle for subprocess preexec_fn
Type: enhancement Stage: needs patch
Components: Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: gregory.p.smith, vstinner
Priority: normal Keywords:

Created on 2019-10-10 18:18 by gregory.p.smith, last changed 2019-10-11 11:00 by vstinner.

Messages (4)
msg354397 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-10-10 18:18
subprocess's preexec_fn feature needs to enter PendingDeprecationWarning state in 3.9, to become a DeprecationWarning in 3.10, with a goal of removing it in 3.11.

Rationale: We now live in a world full of threads, it is entirely unsafe to call back into the python interpreter within the forked child before exec per POSIX specification.

We've also already made preexec_fn no longer supported from CPython subinterpreters in 3.8.

If there are not already issues open for desired features of subprocess that do not yet have replacements or workarounds for *specific* actions that preexec_fn is being used for in your application, please open feature requests for those.  (ex: calling umask is https://bugs.python.org/issue38417, and group, uid, gid setting has already landed in 3.9)
msg354404 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-10 20:44
What is the recommanded way to replace preexec_fn?
msg354407 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-10-10 21:31
With task specific arguments.  cwd, start_new_session, group, extra_groups,
user, etc..

We cannot provide a general do everything replacement and should not try.
It not possible.
msg354439 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-11 11:00
> We cannot provide a general do everything replacement and should not try. It not possible.

Well, I proposed a solution at:
https://bugs.python.org/issue38417#msg354242

I know that this solution has multiple flaws, but a bad solution may be better than no solution: breaking applications when upgrading to Python 3.11.
History
Date User Action Args
2019-10-11 11:00:31vstinnersetmessages: + msg354439
2019-10-10 21:31:38gregory.p.smithsetmessages: + msg354407
2019-10-10 20:44:47vstinnersetnosy: + vstinner
messages: + msg354404
2019-10-10 18:18:17gregory.p.smithcreate