gc win32com server

Paul Paterson hamonlypaulpaterson at houston.rr.com
Sun Jun 1 11:26:18 EDT 2003


I have an application written as a COM server which is py2exe'd and run on
my client's machines. Some VB code creates instances of the Python COM
objects and then uses them. The problem is that, under certain
circumstances, the VB code will exit normally but the COM server will remain
running in the background.

I did some investigation and managed to solve some instances of this problem
by breaking a circular object reference (just doing a del on an
obj.attribute). However, the problem still occurs in other circumstances,
where I know that I have a large structure in Python with circular
references.

My assumption is that the Python gc scheme can't resolve my circular
references and therefore somehow keeps the COM object alive. Is this a
reasonable assumption? Note that no other object has alink to the COM object
itself, the circular references occur on objects which the COM object has a
reference to.

Clearly one approach to resolve the problem might be to remove all circular
references in the code. However, this is a fairly involved job as they are
fairly intrinsic to the code that uses them so "fixing" this would involve a
re-arch of that part of the code.

I have implemented another "fix" - I kill the COM EXE the next time the App
starts. However, this is just plain ugly and is also slow.

Is there a some other way to send the COM server a "die now" message from
the client side?

Alternatively is there something I could do on the gc side to help the
collector sweep up my objects.









More information about the Python-list mailing list