471,056 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,056 software developers and data experts.

pythoncom, CoUninitialize & references


I'm programming something with NeroSDK COM module, and I bumped into a
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
print rc
return rc

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

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

# 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?
Jul 18 '05 #1
0 2012

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gabriel Genellina | last post: by
reply views Thread by leo001 | last post: by

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.