STINNER Victor added the comment: > 1. The call to warnings.warn is not usable during interpreter shutdown (and > running `python -W ignore test.py` has no effect)
Oops right. I just fixed this issue. > 2. Calling "process.terminate()" or "process.kill()" at in the testcase or in > an atexit handler would not get rid of the warning, one must set the return > code on the Popen object Hum. I should document somehow how to fix such bug: you must read the exit status of the child process, not set manually the returncode attribute. You have to call the wait() method of each process after calling terminate(). > 3. The warning can show up in existing code that has absolutely no zombie > problems. I modified your example to list zombi processes: try test2.py. Output: $ ./python test2.py 0 1000 25520 25120 20 0 140940 11828 wait S+ pts/0 0:00 ./python test2.py 0 1000 25521 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25522 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25523 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25524 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25525 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25526 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25527 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25528 25520 20 0 0 0 - Z+ pts/0 0:00 [python] <defunct> 0 1000 25529 25520 20 0 119032 3008 wait S+ pts/0 0:00 sh -c ps l|grep 25520 0 1000 25531 25529 20 0 118540 880 - S+ pts/0 0:00 grep 25520 Lib/subprocess.py:761: ResourceWarning: subprocess 25528 is still running sys:1: ResourceWarning: unclosed file <_io.FileIO name=18 mode='wb' closefd=True> sys:1: ResourceWarning: unclosed file <_io.FileIO name=19 mode='rb' closefd=True> (...) The long list of <defunct> are the zombi processes: it means that the kernel is unable to remove completely child processes because the parent didn't read the exit status yet. Process identifiers and memory are wasted. The warning can also help to detect when an application forgot to check the exit status. At least, if you add a call to process.wait(), it becomes explicit that ignoring the exit status is deliberate. ---------- nosy: +martin.panter Added file: http://bugs.python.org/file46172/test2.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29174> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com