You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix test hang by restoring __main__ state in TestHandlePreload
TestHandlePreload tests call spawn.import_main_path() which modifies
sys.modules['__main__'] and appends to spawn.old_main_modules. This
state persisted after tests, causing subsequent forkserver tests to
try loading __main__ from a deleted temp file. With on_error='ignore',
the forkserver stayed broken causing process spawn failures and hangs.
Fix by adding setUp/tearDown to TestHandlePreload that saves and
restores sys.modules['__main__'] and clears spawn.old_main_modules.
Also add suppress_forkserver_stderr() context manager that injects
a stderr-suppressing module via the preload mechanism itself, avoiding
noisy output during tests that expect import failures.
Thanks to Duane Griffin for identifying the root cause of the hang.
0 commit comments