* glib/dbus-gmain.c (io_handler_dispatch): fix deadlock

when using recursive g_main_loops

* python/_dbus.py (class Bus): add the ProxyObjectClass
  alias for ProxyObject to make it easier for the Twisted
  networking framework to integrate dbus.

* python/proxies.py (class ProxyObject): add the ProxyMethodClass
  alias for ProxyMethod to make it easier for the Twisted
  networking framework to integrate dbus.
This commit is contained in:
John (J5) Palmieri 2005-05-16 21:27:04 +00:00
parent ad5bafed04
commit 63ac302bab
4 changed files with 59 additions and 48 deletions

View file

@ -1,3 +1,16 @@
2005-05-16 John (J5) Palmieri <johnp@redhat.com>
* glib/dbus-gmain.c (io_handler_dispatch): fix deadlock
when using recursive g_main_loops
* python/_dbus.py (class Bus): add the ProxyObjectClass
alias for ProxyObject to make it easier for the Twisted
networking framework to integrate dbus.
* python/proxies.py (class ProxyObject): add the ProxyMethodClass
alias for ProxyMethod to make it easier for the Twisted
networking framework to integrate dbus.
2005-05-11 Ross Burton <ross@burtonini.com>
* glib/dbus-glib-tool.c: Add --prefix argument.

View file

@ -240,13 +240,7 @@ io_handler_dispatch (GIOChannel *source,
handler = NULL;
if (connection)
{
/* Dispatch messages */
while (dbus_connection_dispatch (connection) == DBUS_DISPATCH_DATA_REMAINS)
;
dbus_connection_unref (connection);
}
dbus_connection_unref (connection);
return TRUE;
}

View file

@ -70,6 +70,8 @@ class Bus:
"""bus_type=[Bus.TYPE_SESSION | Bus.TYPE_SYSTEM | Bus.TYPE_STARTER]
"""
ProxyObjectClass = ProxyObject
START_REPLY_SUCCESS = dbus_bindings.DBUS_START_REPLY_SUCCESS
START_REPLY_ALREADY_RUNNING = dbus_bindings.DBUS_START_REPLY_ALREADY_RUNNING
@ -106,7 +108,7 @@ class Bus:
def get_object(self, named_service, object_path):
"""Get a proxy object to call over the bus"""
return ProxyObject(self, named_service, object_path)
return self.ProxyObjectClass(self, named_service, object_path)
def add_signal_receiver(self, handler_function, signal_name=None, dbus_interface=None, named_service=None, path=None):
match_rule = self._get_match_rule(signal_name, dbus_interface, named_service, path)

View file

@ -1,45 +1,5 @@
import dbus_bindings
class ProxyObject:
"""A proxy to the remote Object.
A ProxyObject is provided by the Bus. ProxyObjects
have member functions, and can be called like normal Python objects.
"""
def __init__(self, bus, named_service, object_path):
self._bus = bus
self._named_service = named_service
self._object_path = object_path
def connect_to_signal(self, signal_name, handler_function, dbus_interface=None):
self._bus.add_signal_receiver(handler_function,
signal_name=signal_name,
dbus_interface=dbus_interface,
named_service=self._named_service,
path=self._object_path)
def __getattr__(self, member, **keywords):
if member == '__call__':
return object.__call__
elif member.startswith('__') and member.endswith('__'):
raise AttributeError(member)
else:
iface = None
if (keywords.has_key('dbus_interface')):
iface = keywords['dbus_interface']
return ProxyMethod(self._bus.get_connection(),
self._named_service,
self._object_path, iface, member)
def __repr__(self):
return '<ProxyObject wrapping %s %s %s at %x>'%(
self._bus, self._named_service, self._object_path , id(self))
__str__ = __repr__
class ProxyMethod:
"""A proxy Method.
@ -95,3 +55,45 @@ class ProxyMethod:
else:
return args_tuple
class ProxyObject:
"""A proxy to the remote Object.
A ProxyObject is provided by the Bus. ProxyObjects
have member functions, and can be called like normal Python objects.
"""
ProxyMethodClass = ProxyMethod
def __init__(self, bus, named_service, object_path):
self._bus = bus
self._named_service = named_service
self._object_path = object_path
def connect_to_signal(self, signal_name, handler_function, dbus_interface=None):
self._bus.add_signal_receiver(handler_function,
signal_name=signal_name,
dbus_interface=dbus_interface,
named_service=self._named_service,
path=self._object_path)
def __getattr__(self, member, **keywords):
if member == '__call__':
return object.__call__
elif member.startswith('__') and member.endswith('__'):
raise AttributeError(member)
else:
iface = None
if (keywords.has_key('dbus_interface')):
iface = keywords['dbus_interface']
return self.ProxyMethodClass(self._bus.get_connection(),
self._named_service,
self._object_path, iface, member)
def __repr__(self):
return '<ProxyObject wrapping %s %s %s at %x>'%(
self._bus, self._named_service, self._object_path , id(self))
__str__ = __repr__