Reputation: 1475
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.
Upvotes: 1
Views: 1243
Reputation: 3761
segmentation faults occur because in a python module (written in C) a pointer is NULL, or because it points to random memory (probably never initialized to anything), or because it points to memory that has been freed/deallocated/"deleted".so your problem is probably with your memory.try trace the segfault using methods described here
Upvotes: 1