gc.get_objects()

Matteo Boscolo matteo.boscolo at boscolini.eu
Mon Sep 17 13:23:23 EDT 2012


from my gc.get_object()
I extract the sub system of the object that I would like to delete:

this is the object:
Class name 
win32com.gen_py.F4503A16-F637-11D2-BD55-00500400405Bx0x1x0.ITDProperty.ITDProperty
that is traked and the reference are:
get_referents >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> 
 >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> 
 >>>>>>>>>>>>
RefCount 5
<type 'tuple'> >>>>  (<class win32com.client.DispatchBaseClass at 
0x026ACB58>,)
RefCount 5
<type 'dict'> >>>>  '__int__': <function __int__ at 0x03A50770>, 
'__module__': 'win32com.gen_py.F45
RefCount 8
<type 'str'> >>>>  ITDProperty
RefCount 9
<type 'function'> >>>>  <function __getattr__ at 0x026C2630>
RefCount 9
<type 'function'> >>>>  <function __setattr__ at 0x026C2670>
get_referrers >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> 
 >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> 
 >>>>>>>>>>>>
RefCount 15
<type 'dict'> >>>>  'python_version': 34014192, 'defaultUnnamedArg': 
<PyOleEmpty object at 0x00447E
RefCount 6
<type 'list'> >>>>  <class 
win32com.gen_py.F4503A16-F637-11D2-BD55-00500400405Bx0x1x0.ITDProperty.I
RefCount 4
<type 'list'> >>>>  (u'ItemsListCreator', u'trick', u'pVal'), (3, 49, 
'0', None), (16393, 10, None,
RefCount 4
<type 'frame'> >>>>  <frame object at 0x029721D8>
RefCount 7
<type 'frame'> >>>>  <frame object at 0x02760148>
RefCount 5
<type 'dict'> >>>> '{39AAEA35-F71F-11D2-BD59-00500400405B}': <class 
win32com.gen_py.F4503A16-F637-

how can I understand how to clean up this situation or were are the 
references that I need to delete ?

 From the cad non python script I call an in process python com object, 
and before coming back to the cad application I need to clean up all com 
reference, because if I do not do that I corrupt the cad application .

so I urgently need to clean up all reference before coming back to the 
cad application.

any idea?

regards,
Matteo


Il 17/09/2012 18:09, Chris Angelico ha scritto:
> On Tue, Sep 18, 2012 at 12:16 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> The __del__ method does not delete an object. Remember, objects are only
>> deleted when there are no references to it. Otherwise you could have some
>> code that tries to use a deleted object, and you would get a system crash
>> or BSOD.
> There is a conceptually viable alternative: destroy an object
> immediately and force all references to it to become some sentinel
> value (eg None). Python currently doesn't have this, but it would be
> rather convenient at times. Could be part of a construct like 'with'
> to say "make this, use it, and then dispose of it".
>
> ChrisA




More information about the Python-list mailing list