COM server threads/unloading

Kris J. Zaragoza kzaragoza at attbi.com
Sun Jun 30 21:28:03 EDT 2002


In article <10d944cb.0206281302.43de821a at posting.google.com>, Uncle Enzo wrote:
> Thanks Kris, for your reply. I have a follow-up question...

No problem.  Glad I could help. :)

>> As I see it, you have two options.  First, you can build a mechanism
>> to explicitly send the logger the message to shut down.
> 
> How would you do this? Start another thread that periodically checks
> mainthread.GetInterfaceCount(), and if it returns zero put in the quit
> event and then return? I'd rather not have a shutdown or release
> method exposed to users.
> 

If you don't want to use an explicit shutdown call, look into defining
a __del__ method on your COM object.  These get called when the
reference count on Python objects reaches zero, and I think they get
called when the reference count on the COM object goes to zero and the
object is released.  (Mark the man could say more on this.)  You could
send the magic quit command to the background thread in there.

I'd dig into this more for you, but I'm actually on vacation and
borrowing a pathetically slow dialup line from my cousin.  The docs
for the Python COM extensions should be able to tell you more.

Good luck!

Kris

-- 
Kris J. Zaragoza       | On the face of it, Microsoft complaining about
kzaragoza at attbi.com    | the source license used by Linux is like the
                       | event horizon calling the kettle black.
                       | -- Adam Barr, article on kuro5hin.org



More information about the Python-list mailing list