You actually want to do callbacks it would seem, so em-synchrony isn't actually necessary -- that's actually designed to hide the callbacks, and make it seem more like straightforward single-threaded code.
It is actually possible to run an EventMachine event loop inside Passenger (or other process-based servers) -- you just need to start up the event loop in a separate thread on app initialization. This could possibly suit your needs; I did a similar thing for posting items to PubNub. It might only be useful if you actually are doing multiple HTTP backend requests that can be done in parallel; you're going to need to issue the requests then wait for them all to be done, then render the response. It won't actually make your server any more capable of serving more requests at once, it just might make the requests faster to serve. Overall, it might not be worth it? Simon. On Sun, Dec 4, 2011 at 18:45, Dmytrii Nagirniak <[email protected]> wrote: > > On 04/12/2011, at 9:51 AM, suranyami wrote: > > > On Dec 2, 10:48 pm, Dmytrii Nagirniak <[email protected]> wrote: > There is a 1.8 fiber library, which I did manage to use and get EM > working: > > https://github.com/tmm1/fiber18 > > > Good to know that. Thanks. > > Don't do the view > rendering (the response), until the callback you register in the first > part has been called. > > Refactoring your code in arbitrary pseudo-code: > > response = Post.find(123) > response.callback do |result| > render result # using post.title, etc... > end > > > I realise that it's better not to do any logic in the view. But that is > "hidden" logic. > I don't see anything wrong with starting the rendering (or doing anything > else) in advance. There is really no need to block the whole thread just to > wait for 3 HTTP requests. > (Streaming in Rails 3 is a similar example of this). > > Also I am not sure that rendering with callback will work in Rails. You > always need to render at the end of the request. What the response is if you > don't render anything? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" 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/rails-oceania?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" 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/rails-oceania?hl=en.
