Prev: TypeError: _new_() takes exactly 3 arguments (2 given) - what doesit mean?
Next: Python and Tkinter Programming by John Grayson
From: moerchendiser2k3 on 29 May 2010 08:34 Hi at all, I have a small problem with Py_single_input, that I dont really know what it actually does. I created my own interactive interpreter loop and when I create objects like p = TestObject() this instance is just deleted on Py_Finalize() even I delete the entire console scope long time before. It seems that Py_single_input stores the references somewhere else. Could anyone explain me a little bit what is actually going on here? Thanks a lot! Cheers, moerchendiser2k3
From: moerchendiser2k3 on 30 May 2010 06:17 Hi, any idea?
From: Carl Banks on 30 May 2010 21:31 On May 30, 3:17 am, moerchendiser2k3 <googler. 1.webmas...(a)spamgourmet.com> wrote: > Hi, any idea? Python doesn't guarantee that objects will be deleted at a specific time. There are different reasons why an object might not be deleted. In command line mode Python keeps a reference to the most recent result. I don't know if it happens in general for any Py_single_input, but you could try to execute a few dummy commands with Py_single_input to see if it helps. But if you're relying on that behavior you really need to consider rethinking your problem. The only foolproof way to ensure that an object has been finalized is to do it manually (i.e., provide a finalize method to releases resources). Carl Banks
From: moerchendiser2k3 on 31 May 2010 06:10 Hi Carl, thanks for your help!! > The only foolproof way to ensure that an object has been finalized is > to do it manually (i.e., provide a finalize method to releases > resources). Yes, you are right, thats what I thought, too. So I wanted to manually delete the reference, but browsing the sources, seems that I cant really free it, because its wrapped somewhere in Py_Finalize() and PyGC_Collect and Py_FreeModules. Any ideas? Thanks a lot! Cheers, moerchendiser2k3
From: moerchendiser2k3 on 31 May 2010 07:11
Hi Carl, you are right, Python still holds the last reference. I just set a dummy and thats it :) Can you tell me where did you get the information from? Thanks! |