[PYDBUS]Export method question

Robert McQueen robert.mcqueen at collabora.co.uk
Fri Oct 28 17:00:37 PDT 2005


Claudio Takahasi wrote:
> Hi folks,

Hola,

> When I send a method call "PwdRequest" the application is started
> automatically, however I CAN'T reply immediately because the reply
> content is not available.  The reply data(password) will become
> available only when the user presses the button(OK). How can I design
> it?

This is a valid problem. Unfortunately there is no solution to this in
the python bindings at the moment. All method implementations must
complete synchronously, which makes it hard to do anything like a UI or
a network operation.

Your current options are (in increasing order of disruption):
 * Make a horrible hack that keeps iterating the mainloop inside your
method until the dialog has been responded to by the user. This can get
ugly because whilst you're in the mainloop inside your PwdRequest
method, you could get another call to enter the PwdRequest method
again... insanity may ensue. Its also a good way to get stack overflows,
huge backtraces, and other horribleness.
 * Make the PwdRequest application emit a signal when the user has
entered the password.
 * Swap the roles of your server and client so the client, when
activated, prompts for the password, and then invokes a method on the
server to provide the password when it has been input.
 * Use the glib bindings which implement asynchronous methods in
services. :-/

It's quite high on my todo list to fix it so you can have asynchronous
method implementations, because I'm trying to prototype code that talks
on the network...

> Thanks in advance,
> Claudio

Regards,
Rob


More information about the dbus mailing list