maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   dbus-python: How to not to ask for a reply? (https://talk.maemo.org/showthread.php?t=71965)

laasonen 2011-04-10 07:47

dbus-python: How to not to ask for a reply?
 
How to not to ask for a reply? Thanks.
Code:

import dbus
bus = dbus.bus.BusConnection("unix:path=/var/run/dbus/system_bus_socket")
object = bus.get_object('com.nokia.mce', '/com/nokia/mce/request')
interface = dbus.Interface(object, dbus_interface='com.nokia.mce.request')
interface.devlock_callback(dbus.Int32("2"))

Code:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.5/dbus/proxies.py", line 68, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/pymodules/python2.5/dbus/proxies.py", line 140, in __call__
    **keywords)
  File "/usr/lib/pymodules/python2.5/dbus/connection.py", line 622, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.


jstokes 2011-04-10 09:35

Re: dbus-python: How to not to ask for a reply?
 
Apparently you're supposed to set error_handler and reply_handler to None. When I did that, though, it didn't send the message.

I worked around it like this:
Code:

import dbus

bus = dbus.bus.BusConnection("unix:path=/var/run/dbus/system_bus_socket")
object = bus.get_object('com.nokia.mce', '/com/nokia/mce/request', introspect=False)
interface = dbus.Interface(object, dbus_interface='com.nokia.mce.request')
try:
        interface.devlock_callback(dbus.Int32("2"), timeout = 0)
except dbus.exceptions.DBusException:
        pass


laasonen 2011-04-10 14:28

Re: dbus-python: How to not to ask for a reply?
 
Quote:

Originally Posted by jstokes (Post 984940)
Apparently you're supposed to set error_handler and reply_handler to None. When I did that, though, it didn't send the message.

I worked around it like this:
Code:

import dbus

bus = dbus.bus.BusConnection("unix:path=/var/run/dbus/system_bus_socket")
object = bus.get_object('com.nokia.mce', '/com/nokia/mce/request', introspect=False)
interface = dbus.Interface(object, dbus_interface='com.nokia.mce.request')
try:
        interface.devlock_callback(dbus.Int32("2"), timeout = 0)
except dbus.exceptions.DBusException:
        pass


Thanks again, sorry for my poor dbus skills :(

auouymous 2011-04-11 05:31

Re: dbus-python: How to not to ask for a reply?
 
In C you would create a "method call" message, append the args and then call dbus_message_set_no_reply(message, TRUE) before sending it.

It looks like Python has a set_no_reply(message, bool) method that might do the same.

http://dbus.freedesktop.org/doc/dbus...age-class.html


All times are GMT. The time now is 04:25.

vBulletin® Version 3.8.8