[issue25654] test_multiprocessing_spawn ResourceWarning with -Werror

Serhiy Storchaka report at bugs.python.org
Fri Mar 25 07:07:50 EDT 2016


Serhiy Storchaka added the comment:

> Oops, I forgot to discuss the second part :-) You also added "sys.__stderr__ = sys.stderr" in multiprocessing.

At the start of PyImport_Cleanup() sys.stdXXX is set to sys.__stdXXX__. If sys.stdXXX is not sys.__stdXXX__ and here is the last reference to the stream, this causes deallocating sys.stdXXX and emitting a resource warning. If set sys.__stdXXX__ to sys.stdXXX, deallocating the stream is deferred to the end of PyImport_Cleanup(). Other changes make PyImport_Cleanup() to close standard streams explicitly before deallocating, thus resource warning are not emitted.

This workaround is not needed if deallocating sys.stdin doesn't emit a resource warning (since it is opened with closefd=False). But it still may be needed in tests if apply proposed changes to PyImport_Cleanup(), since sys.stderr is set to a file opened with closefd=True.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25654>
_______________________________________


More information about the Python-bugs-list mailing list