[Python-Dev] Behavior change in subprocess.py
Delaney, Timothy (Tim)
tdelaney at avaya.com
Fri Jul 21 02:44:39 CEST 2006
Hah - just found it. I even remember reading it...
I'll update the SF tracker (1526203) with your analysis.
Tim Delaney
-----Original Message-----
From: python-dev-bounces+tdelaney=avaya.com at python.org
[mailto:python-dev-bounces+tdelaney=avaya.com at python.org] On Behalf Of
Kevin Jacobs <jacobs at bioinformed.com>
Sent: Thursday, 13 July 2006 12:33 AM
To: python-dev at python.org
Subject: [Python-Dev] 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060721/c21df170/attachment.html
More information about the Python-Dev
mailing list