<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Simon McVittie Wrote:<BR><BR>> I suspect your service implementation is at fault here. What ought to<BR>> happen is that the binding calls your service implementations on a queue<BR>> basis, but the service implementations return almost immediately:<BR>
<BR>
I suspect you might be right with this, I just copied the service concept from some code I found in the examples folder of the source, however, it might not be async, I notice they gave an async example of a client along with a standard one, but no apparant async example of a service.<BR>
<BR>
Looking at the code example you gave below, I notice a few things which are different from my service, namely the references to the async_callbacks=('reply_cb', 'error_cb')) This is something which isn't currently implemented in my service, also, My current function doesn't return False, I have it return the results of the function, opposed to passing it to the return_cb or error_cb methods.<BR>
<BR>
Are you able to give me some examples of return_cf and error_cf functions and how they should be placed within the service? I would really appreciate that.<BR><BR>> The underlying framework you're using for the web-service requests will<BR>> have to be able to run asynchronously too.<BR>
<BR>
This is also a great point, and at the moment I cant guarantee that it will be, however, I'm confident that it is, I've used other methods on it async style which send back signals which I listen for. I just want to get my own service to a point where I can be sure its Async, and if I'm still having problems then look at some threading choices.<BR>
<BR>
Thanks Simon, if you wouldn't mind showing me an example of how to implement callbacks in the service I would owe you a beer.<BR>
<BR>
Robert<BR>
<HR id=stopSpelling>
<BR>
> Date: Thu, 7 Feb 2008 13:26:17 +0000<BR>> From: simon.mcvittie@collabora.co.uk<BR>> To: dbus@lists.freedesktop.org<BR>> Subject: Re: Making asynchronous calls<BR>> <BR>> -----BEGIN PGP SIGNED MESSAGE-----<BR>> Hash: SHA1<BR>> <BR>> On Thu, 07 Feb 2008 at 12:13:54 +0000, Robert Rawlins wrote:<BR>> > When I run this client code it prints "Made Calls" almost immediately and then over the next 10 seconds or so the service appears to call my callbacks and print the results of the calls to the screen, exactly as I would expect it too. However, If I change that first call to a web address I know doesn't work properly and will return really slowly then I don't get any callbacks called until the first web service call has timed out, then they are both called nice and quickly.<BR>> > <BR>> > Do you see what I mean? My service appears to be quing my requests, which means that if one request runs slowly then it clogs up the queue.<BR>> <BR>> I suspect your service implementation is at fault here. What ought to<BR>> happen is that the binding calls your service implementations on a queue<BR>> basis, but the service implementations return almost immediately:<BR>> <BR>> @dbus.service.method('com.example.Crack', in_signature='s',<BR>> out_signature='s',<BR>> async_callbacks=('reply_cb', 'error_cb'))<BR>> def MakeHTTPRequest(self, url, reply_cb, error_cb):<BR>> # this is a fake implementation that pretends the server replied<BR>> # after 15 seconds<BR>> def timeout_func():<BR>> reply_cb('404 Not Found\r\n')<BR>> return False<BR>> gobject.timeout_add(15000, timeout_func)<BR>> <BR>> The underlying framework you're using for the web-service requests will<BR>> have to be able to run asynchronously too.<BR>> <BR>> If it can't, you could hack up some solution where the D-Bus method<BR>> implementation fires off a worker thread that makes a synchronous<BR>> request, the result from that thread is communicated back to the<BR>> main thread somehow (perhaps with a pipe-to-self), and the main thread<BR>> responds by calling the reply_cb.<BR>> <BR>> Simon<BR>> -----BEGIN PGP SIGNATURE-----<BR>> <BR>> iD8DBQFHqwb5WSc8zVUw7HYRApnUAKCeXobLHciESHURQZNGDTtWXRetbwCghyIU<BR>> Cyy/kXhWn22wqtIE3LTHgZU=<BR>> =M8EW<BR>> -----END PGP SIGNATURE-----<BR>> _______________________________________________<BR>> dbus mailing list<BR>> dbus@lists.freedesktop.org<BR>> http://lists.freedesktop.org/mailman/listinfo/dbus<BR><BR><br /><hr />She said what? About who? <a href='http://www.msnsearchstar.com' target='_new'>Shameful celebrity quotes on Search Star!</a></body>
</html>