"[5164] Failed calling of COM event: Member not found"

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

mcow
Posts: 815
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

"[5164] Failed calling of COM event: Member not found"

Post by mcow » Mon Dec 31, 2012 3:34 pm

I recently got the DbgView program. I have a webserver extension for MM, written in Python, that uses the COM interface.

I first noticed that when my server is running with MM_dbg (4.07) that the DbgView window is showing these messages, two or three at a time:
"[5164] Failed calling of COM event: Member not found"

To debug this, I closed the server (which stopped the messages), opened a Python window, and stepped thru the server setup. I notice that as soon as I instantiate a COM object with Event support, DbgView starts spewing out those messages, in much larger numbers: maybe twelve at a time. It's hard to tell from the timestamps exactly how these are spaced, but there does seem to be pause between groups of messages. These keep getting dumped until the dispatch object is destroyed.

When the server is running, the event-handling object is polled about every half-second by a background thread. The polling queries Player.isPlaying, Player.StopAfterCurrent, and Player.CurrentSongIndex. That's it; no other interaction with the object. But once that thread starts, the number of messages output at at time drops to just a few, like I originally saw.

I'm guessing this means my object is supposed to have event-handling methods that are not being detected, but those methods should be in place. My application gets the events as expected, but it's only handling six events explicitly. The default behavior is supposed to be built into the COM object; there shouldn't be any missing anything.

How can I figure out what's missing here, and how can I find out whether it's important?

mcow
Posts: 815
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

Re: "[5164] Failed calling of COM event: Member not found"

Post by mcow » Thu Feb 14, 2013 11:04 pm

I did some debugging with this, and I was able to prevent the log entries by adding a do-nothing OnIdle() method to my event-handling object. This shouldn't be necessary; my object piggybacks on the default COM object, which has an OnIdle() itself that I would have expected to be called.

This symptom was seen in 4.0.7 as well as 4.1. On the weekend, I'll put together a pair of scripts that can easily demo the issue.

I am having problems with my Python script not closing after receiving the OnShutdown notification; it does all the shutdown things it needs to, but never exits, and then MM won't completely close either. It's like the Python object is not detaching from the MM app.
If I kill Python before closing MM, then MM closes fine. I can't say whether this has anything to do with the OnIdle quirk; I think probably not.

mcow
Posts: 815
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

Re: "[5164] Failed calling of COM event: Member not found"

Post by mcow » Sat Feb 16, 2013 2:24 pm

As promised, here are the scripts to reproduce the symptom.
In addition, there seems to be a repeatable (but not consistent) crash associated with the COM object in 4.1.
Steps to reproduce:
0) On the test system, have an installed version of (32-bit) Python and the pywin32 extension that matches it. I'm using python 2.7.
1) Run DbgView
2) Run debug version of MM 4.x
3) In a command-line window, run ShutdownOnly.py
4) Observe DbgView window: line after line of "Failed calling of COM event: Member not found" entries appear
5) Shutdown MM, script will terminate automatically

If you run ShutdownAndIdle.py instead, the log lines do not appear.

In addition, with MM 4.1 builds (1624, and seen in earlier builds), it will often crash on shutdown. I have a log file with the entries surrounding that crash, available on request.

ShutdownOnly.py:

Code: Select all

# monitor player events from MediaMonkey.  print event flag and player state info for each
# note: once started, script does not exit until MM is shut down.
import win32com.client
import pythoncom
import time

quit = False

class MMEventHandlers():

    def __init__(self):
        pass

    def OnShutdown(self):
        global quit
        print '>>> SHUTDOWN >>>' 
        quit = True


def monitor():
    # running the script will start MM if it's not already running
    SDB = win32com.client.DispatchWithEvents('SongsDB.SDBApplication', MMEventHandlers)

    print "** monitor started"
    while not quit:
        pythoncom.PumpWaitingMessages()
        time.sleep(0.2)

    print "** monitor stopped"

if __name__ == '__main__':
    monitor()
ShutdownAndIdle.py:

Code: Select all

# monitor player events from MediaMonkey.  print event flag and player state info for each
# note: once started, script does not exit until MM is shut down.
import win32com.client
import pythoncom
import time

quit = False

class MMEventHandlers():

    def __init__(self):
        pass

    def OnShutdown(self):
        global quit
        print '>>> SHUTDOWN >>>' 
        quit = True

    def OnIdle(self):
        pass


def monitor():
    # running the script will start MM if it's not already running
    SDB = win32com.client.DispatchWithEvents('SongsDB.SDBApplication', MMEventHandlers)

    print "** monitor started"
    while not quit:
        pythoncom.PumpWaitingMessages()
        time.sleep(0.2)

    print "** monitor stopped"

if __name__ == '__main__':
    monitor()

Post Reply