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 charles.mcmarrow.4, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-10-28.03:36:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603856186.84.0.981925098832.issue42178@roundup.psfhosted.org>
In-reply-to
Content
Due to the exception raised when trying to pickle main.<locals>.dummy in popen_spawn_win32.Popen(), the main process may have already exited by the time the spawned worker calls WinAPI OpenProcess in spawn.spawn_main(). I suppose the reduction of prep_data and process_obj  in popen_spawn_win32.Popen() could be dumped to an io.BytesIO instance before WinAPI CreateProcess is called. That way an exception in the pickler would occur before the child process is created.

There's also a race condition that can hang the worker during interpreter startup. When sys.stdin is initialized, the buffered reader does a raw tell(). If the raw layer is an io.FileIO instance (e.g. console input with PYTHONLEGACYWINDOWSSTDIO defined), the raw tell() ultimately calls WinAPI SetFilePointerEx (via _lseeki64). This can hang if the kernel file is already blocked in a synchronous I/O request, which might be the case if the main process has already terminated and its parent (e.g. cmd.exe or powershell.exe) has resumed reading from the console. portable_lseek() in Modules/_io/fileio.c should detect a non-disk file via WinAPI GetFileType and just set self->seekable to 0 in this case.
History
Date User Action Args
2020-10-28 03:36:26eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, charles.mcmarrow.4
2020-10-28 03:36:26eryksunsetmessageid: <1603856186.84.0.981925098832.issue42178@roundup.psfhosted.org>
2020-10-28 03:36:26eryksunlinkissue42178 messages
2020-10-28 03:36:26eryksuncreate