Oh yes, del was exactly what I was looking for.Bitmonster wrote:Well, this is problematic. Normally Python releases the dispatch to the COM object as soon as every reference to the COM object is deleted. So you can do something like:
del self.MM
self.MM = None
The problem is, that we don't know when MediaMonkey wants to close, as we have no direct event callback. One possibility might be to get and release the dispatch on every command.
Code: Select all
def DoCommand(command): mm = Dispatch("SongsDB.SDBApplication") getattr(mm.Player, command)() del mm DoCommand("Play")
We actually do have an event callback, via Pako's MediaMonkey autoscript (in this case Main.MM_finishing would be the one). So that could actually work.
Releasing the dispatch on every command works! That is unless the dispatch started the MediaMonkey application - then Mediamonkey will close on every command.
EDIT: My bad. I forgot the ShutdownAfterDisconnect=False. It works like a charm! Thank you, guys!