Deffered and DbusMainLoop
- From: Anders Gnistrup <agn datarespons dk>
- To: "networkmanager-list gnome org" <networkmanager-list gnome org>
- Subject: Deffered and DbusMainLoop
- Date: Mon, 15 Aug 2011 14:47:57 +0200
Hi
I have a problem, which I can not solve. I have an application, which have a XML interface (based on twisted.web import xmlrpc)
I have a snippet of code that is be called via the xmlrpc interface.
def ssidList(self):
def ssid_blocking():
wlan_list = []
for apDict in self.wifi.GetAccessPointsInfo():
if apDict['Ssid'] != None:
val = apDict['Ssid']
str_val = ""
for elt in val:
# This test should not be needed, but prevents crashes.
if type(elt) == type(dbus.Byte(1)):
str_val += chr(elt)
wlan_list.append({ 'ssid' : str_val } )
return wlan_list;
# return ssid_blocking()
d = threads.deferToThread(ssid_blocking)
def retResult(var):
return var
d.addCallback(retResult)
return d
If I remove the # before "# return ssid_blocking()" everything works just fine (no use of deferToThread). If I try to use the defreToThread method, the program crashes. The problem seems to be related to the usage of DBusGMainLoop(set_as_default=True).
My theory is that when entering a deferToThread a new thread is created, but the dbus mainloop lives in another thread.
The call that makes the program crashes is when calling bus.get_object (bus is a dbus.SystemBus())
My goal is to create a nonblocking xmlrpc interface.
Can anyone give an explanation, or describe a alternative solution.
/AG
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]