473,498 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pythoncom, CoUninitialize & references

Hey,

I'm programming something with NeroSDK COM module, and I bumped into a
problem:
why doesn't python releases and uninitializes COM objects that are no
longer referenced?

Here is a sample code:
# start of sample code
from win32com.client import *

nero = None

def find_backpack_cd():
drives = nero.GetDrives(constants.NERO_MEDIA_CD)
rc = None
for d in drives:
if d.DeviceName.find("BACKPACK") != -1:
rc = d
break
del(drives)
print rc
return rc

def main():
global nero
nero = Dispatch("Nero.Nero")
cd = find_backpack_cd()
del(cd)
del(nero)

if __name__ == "__main__":
main()
print pythoncom._GetInterfaceCount()
pythoncom.CoFreeUnusedLibraries()
pythoncom.CoUninitialize()

# end of sample code

the problem is as follows, if for example, I remove the line
'del(nero)' in function main(), the _GetInterfaceCount() is 1 and
CoUninitialize() fails.
And if I remove the explicit call to CoUninitialize() (and the
interface count is greater than 0) the next time I run the program it
fails with exception that the neroAPI is already initialized (deducing
that it is somehow still in memory).

Doesn't python should get rid of all instances of the COM objects
through its garbage collector?
Thanks,
Omer.
Jul 18 '05 #1
0 2333

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
12279
by: Paul | last post by:
Hi I'm trying to build a standalone COM exe server using Python 2.2 + Mark Hammond's windows extensions + Py2Exe. I've built the example linked on the Py2Exe homepage and get this error when...
5
3943
by: Brian Hlubocky | last post by:
I'm have a fairly simple (in terms of COM) python program that pulls info from an Access database and creates Outlook contacts from that information. It uses wxPython for gui and works without...
6
2728
by: gcmartijn | last post by:
H! I using a script that opens a internet page in a small window (what I can control) In XP everything was working fine, but now I'm using Vista with IE7 and this is what happends now: First...
0
1688
by: Gabriel Genellina | last post by:
En Wed, 27 Aug 2008 21:17:22 -0300, Vistro <vistro@vistro.netescribi�: Reinstalling the pywin32 package should fix that, I presume. In fact that __import_whatever function does a rather...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.