Skip to content

Tempfile.mkstemp file descriptor issue #142302

@QuiteAFoxtrot

Description

@QuiteAFoxtrot

Documentation

In the documentation for https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp

It states The file descriptor is not inherited by child processes.

However, taking a look through https://github.com/python/cpython/blob/main/Lib/tempfile.py there are no indicators of any registering of any close-on-fork or close-on-exec functions or anything exotic to ensure that child processes cannot inherit this file descriptor. The file descriptor is also created in a very normal manner via fd = _os.open(file, flags, 0o600). Additionally, there is empirical evidence this is not true, as we are successfully using the inherited file descriptor in child processes in our codebase (DESI-UR/VAST), so this detail in the documentation appears to be at minimum, not the whole story, and possibly just incorrect.

Perhaps there is some case where it is true (maybe on Windows using multiprocessing 'spawn') or something along those lines?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    No status

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions