This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, pablogsal, pemryan, pitrou, s0undt3ch, vstinner
Date 2021-03-30.15:36:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617118567.77.0.665186783881.issue38263@roundup.psfhosted.org>
In-reply-to
Content
spawn_main() could handle a PermissionError by checking the exit code. If the parent has terminated already, then simply exit quietly. _winapi.PROCESS_QUERY_LIMITED_INFORMATION would need to be defined. For example:

    def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
        """Run code specified by data received over a pipe."""
        assert is_forking(sys.argv), "Not forking"

        if sys.platform == 'win32':
            import msvcrt
            import _winapi

            if parent_pid is not None:
                source_process = _winapi.OpenProcess(
                    _winapi.SYNCHRONIZE |
                    _winapi.PROCESS_DUP_HANDLE |
                    _winapi.PROCESS_QUERY_LIMITED_INFORMATION,
                    False, parent_pid)
            else:
                source_process = None
            try:
                new_handle = reduction.duplicate(
                    pipe_handle, source_process=source_process)
                fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
                exitcode = _main(fd, source_process)
            except PermissionError:
                if (source_process is None or
                      _winapi.GetExitCodeProcess(source_process) ==
                      _winapi.STILL_ACTIVE):
                    raise
                exitcode = 1
        else:
            from . import resource_tracker
            resource_tracker._resource_tracker._fd = tracker_fd
            exitcode = _main(pipe_handle, os.dup(pipe_handle))

        sys.exit(exitcode)
History
Date User Action Args
2021-03-30 15:36:07eryksunsetrecipients: + eryksun, pitrou, vstinner, s0undt3ch, pablogsal, pemryan
2021-03-30 15:36:07eryksunsetmessageid: <1617118567.77.0.665186783881.issue38263@roundup.psfhosted.org>
2021-03-30 15:36:07eryksunlinkissue38263 messages
2021-03-30 15:36:07eryksuncreate