[PyQt] How to Disconnect a python QDBus connection?

Shahin Azad ishahinism at gmail.com
Mon Sep 17 19:38:14 BST 2012


I made some kind of answering machine for pidgin client that uses Linuxes
DBus to make connection with pidgin. the code is this:

    class DBus_Answer():
        def __init__(self, text = "No text"):
            self.answer = text
            bus_loop = DBusQtMainLoop(set_as_default=True)
            self.bus = dbus.SessionBus()
            self.bus.add_signal_receiver(self.pidgin_control_func,

dbus_interface="im.pidgin.purple.PurpleInterface",
                                         signal_name="ReceivedImMsg")

        def pidgin_control_func(self, account, sender, message,
conversation, flags):
            obj = self.bus.get_object("im.pidgin.purple.PurpleService",
"/im/pidgin/purple/PurpleObject")
            purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
            purple.PurpleConvImSend(purple.PurpleConvIm(conversation),
self.answer)

now I want to use it as a module in another program. I called it like this:

    answering_machine.DBus_Answer(message)

the problem is, when I stop the second program (the program that has this
one as a module) and then start it again, I'll get a `segmentation fault`
because it want to make another connection to the DBus and it seams it's
not regular!

Other wise I want to give the chance of disabling this module to user. I
tried to use an `if` statement. It will work for the first time. but if
user run the module for once, he can't disable it any more.


-- 
*Shahin Azad!*
My personal *blog*: http://shahinism.com
I like to keep it respectful with *OpenRespect* (http://www.openrespect.org)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120917/a2a417aa/attachment.html>


More information about the PyQt mailing list