During my testing of Python 2.5b2, I've found something that may be worthy of discussion. I suspect that recent GC and finalization changes have altered the behavior of the Popen object in subprocess.py. I am now getting many many many finalization warnings in my code like:
<br><br>Exception exceptions.AttributeError: "'NoneType' object has no attribute 'append'" in <bound method Popen.__del__ of <subprocess.Popen object at 0x2aaaab910950>> ignored<br><br>Is this a bug or a feature? Personally, I'd like to see these messages silenced, since it is being generated during interpreter shutdown. The following patch does the trick for me:
<br><br>--- /usr/local/lib/python2.5/subprocess.py 2006-07-11 14:11:59.000000000 -0400<br>+++ subprocess.py 2006-07-12 10:17:09.000000000 -0400<br>@@ -613,7 +613,7 @@<br> return<br> # In case the child hasn't been waited on, check if it's done.
<br> self.poll(_deadstate=sys.maxint)<br>- if self.returncode is None:<br>+ if self.returncode is None and _active is not None:<br> # Child is still running, keep us alive until we can wait on it.
<br> _active.append(self)<br><br><br>Note that popen.py does something similar, though I am not convinced that the test is right or if it is doing something more subtle:<br><br> def __del__(self):<br> # In case the child hasn't been waited on, check if it's done.
<br> self.poll(_deadstate=sys.maxint)<br> if self.sts < 0:<br> if _active:<br> # Child is still running, keep us alive until we can wait on it.<br> _active.append(self)
<br><br>Regards,<br>-Kevin<br><br>