On 16-Dec-06, at 8:25 PM, Rol El wrote:
> > Hello, > > I have the same exact question about how to use asynchronous calls in > TG. > > I have a library which talks to a remote server, and it might take a > few millisecs to never i guess.. The way i talk to it is thru a > callback. > > The page request comes in the controller.. then I call > GetMeTheData(myCallBack. arg1, arg2)... this function immediately > returns. Then i have to wait for the "myCallBack" to get the data > before I return from the controller. Anyone have ideas on how to do > this thru TG? Hmm, it's a bit difficult to say without knowing more on what your application has to do. What does GetMeTheData do? Does it spawn off another thread that fetches the data? It seems that what you're trying to do is make an asynchronous action synchronous. As far as I can see you have three options: - Change GetMeTheData so it is synchronous, i.e. only returns after it gets the data instead of returning right away. Then you can just call myCallBack yourself, or do whatever it does in-line. - Add some sort of locking in place so that GetMeTheData releases some lock and the controller method that calls it waits for that lock. - Return from the controller immediately, and create some AJAX code that would run on the client and poll the server at regular intervals (say 5 seconds) and show the user the results when they come back. It really depends on whether you can modify the code in GetMeTheData and on what you're trying to achieve from the user's point of view (asynchronous or synchronous UI). Igor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

