Question

I'm trying to implement a Rhythmbox-plugin similiar to rhythmweb, but I have a problem with starting a HttpServer from within the plugin.

If I start the server like it is usually done (e.g. with make_server(...).server_forever()) the plugin blocks rhythmbox. So I looked at rhythmweb, but I get a segfault everytime I start a request to the server. That is what I do:

class WSGIRefWebServer(IDjangoWebServer):
def __init__(self, host, port, settings):
    IDjangoWebServer.__init__(self, host, port, settings)

def _start_server(self):
    django_handler = django.core.handlers.wsgi.WSGIHandler()
    self.__server = make_server(self._host, self._port, django_handler)
    self._is_running = True

    def request_loop(source, cb):
        self.__server.handle_request()
        return True

    gobject.io_add_watch(self.__server.socket, gobject.IO_IN, request_loop)

If I replace the last line with self.__server.server_forever() everything works fine, but rhythmbox is blocked.

My second approach was to start the webserver in a new thread, which works pretty well, but then I have some trouble using the rhythmbox shell object in the django application.

So I'm looking for a way, to start a webserver, that doesn't block rhythmbox but runs in the same thread. I can't see why the first approach results in a segfault, since rhythmweb does it the same way.

I hope you can help me with my problem.

btw.: I'm using python 2.7 and rhythmbox 2.97 on debian squeeze (testing)

Was it helpful?

Solution

After looking over the code at github.com/fossfreedom/rhythmweb I was able to determine the problem:

I was importing gobject instead of GObject from gi.repository. Now everything works well! :)

Thanks to fossfreedom for the hint!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top