Disconnecting from COM server ?

Tom its1louder at yahoo.com
Thu May 2 17:57:21 EDT 2002


I think an explicit way to do it is like this:
>>> o = win32com.client.Dispatch('your.object')
 
when you're done with it, do 
>>> del o
del will destroy the instance of win32com.client.  If you then try to
run o.method() it will fail because o no longer exists.

But I don't think that's the problem.  I've used win32com.client lots
and I get a lot of mileage out of the activex control wrapper for
wxpython (which uses win32com.client).  I use the same activestate
pythons, 2.1 and 2.2.  I don't get the error you mention in that
context and I never do the 'del o' bit.

But I do get the error.  A lot.  Here are the situations when I get
it:

at home, my DVD player crashes out with that error occasionally.  I
get it at exactly the same instant in the movies without fail,
everytime.  This is a software codec, the free one.

at work I have two computers, and it happens repeatably when I'm doing
different programming tasks.  Can't remember which tasks exactly, but
I've been able to repeat it when I bother to try on either machine. 
One occasion I remember is running the wxpython demo for internet
explorer activex control.  THe Adobe Acrobat one worked fine, though. 
This was repeatable on one work computer, but wouldn't happen on the
other one when running the same demo.

Do a search on the ng's for "referenced memory at " or similiar, and
you'll see it happens to lots of VB users.

I think there's a bug in Win2k or else in the implementation of COM. 
Loose pointers or something.  VB uses COM a lot.




Axel Kowald <kowald at molgen.mpg.de> wrote in message news:<3CD12F0B.8020408 at molgen.mpg.de>...
> Hello,
> 
> I'm using Activestates Python (2.1 & 2.2) to connect to a COM server (win32com.client.Dispatch()). The problem is that python crashes when the script finally terminates ("The instruction at ... referenced memory at .... The memory could not be read"). 
> I guess before exiting I should properly disconnect from the COM server, but what is the proper way ?
> 
> Many thanks,
> 
>                     Axel



More information about the Python-list mailing list