[Rhythmbox-devel] Calling an executable for each song in rb library



Hi all,

I'm working on a plugin that will build playlists and add songs the
play queue based on music feature similarities.  I've created a
feature extraction program in C++ using the Marsyas music analysis
library, and I've started working on a python plugin to call this
program from Rhythmbox.  I am, however, a little stuck.

Right now, I'm looping through the songs in the library as follows:
library = self.shell.get_property('library-source')
for row in library.props.query_model:
	self.scan_song(self.db, row[0])

The important bits of the "scan_song" function looks like this:
pid, stdin, stdout, stderr = gobject.spawn_async(['/path/to/fextract',\
	songfile, vecfile], flags=gobject.SPAWN_DO_NOT_REAP_CHILD)
gobject.child_watch_add(pid, self.process_complete)
gobject.timeout_add(5, self.timeout, pid, songname)

Basically, I want to be able to run the executable ('fextract') on
each song without causing the gui to lock up (takes about a second per
song), but I only want one instance running at a time.  If I just use
gobject.spawn_async, I end up with way too many fextract calls, so I
added in the child_watch_add so that I could set a switch to make sure
that the next one only executes after the previous is finished.

Here's the problem: neither "self.process_complete" or "self.timeout"
ever seem to run (they contain print statements that don't get
printed, and even syntax errors that are never touched).  There's a
few songs that, for whatever reason, cause my executable to hang up,
so I wanted to use the timeout function to skip those songs, but what
ends up happening is everything (rhythmbox included) just freezes up.

Any suggestions?  I've also tried various things with
subprocess.Popen, gobject.idle_add, os.spawn*... I don't really know
what the best approach is, and nothing seems to work.  I've also tried
using a different executable (some simple tests with aplay) to see if
it was my program that was causing the problem, but this is not the
case.

Thanks,

Charlotte


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]