Behavior change in subprocess.py

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: Exception exceptions.AttributeError: "'NoneType' object has no attribute 'append'" in <bound method Popen.__del__ of <subprocess.Popen object at 0x2aaaab910950>> ignored 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: --- /usr/local/lib/python2.5/subprocess.py 2006-07-11 14:11: 59.000000000 -0400 +++ subprocess.py 2006-07-12 10:17:09.000000000 -0400 @@ -613,7 +613,7 @@ return # In case the child hasn't been waited on, check if it's done. self.poll(_deadstate=sys.maxint) - if self.returncode is None: + if self.returncode is None and _active is not None: # Child is still running, keep us alive until we can wait on it. _active.append(self) 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: def __del__(self): # In case the child hasn't been waited on, check if it's done. self.poll(_deadstate=sys.maxint) if self.sts < 0: if _active: # Child is still running, keep us alive until we can wait on it. _active.append(self) Regards, -Kevin
participants (1)
-
Kevin Jacobs <jacobs@bioinformed.com>