Hi Stefan, > Also, you dropped the blocking 'sleep(10)'. :) > As I said to Dotan, I got a "premature connection close" even before adding the sleep call. So that was not the problem.
> > I don't think $delay needs to be declared outside; and for $ua, you might > be able to use $self->ua > > https://gist.github.com/s1037989/8817941 > > Then I realised that it made sense that I couldn't handle the delay end callback if delay were no more defined as I would have left the recurring callback before getting the HTTP response. So I just moved $ua and $delay declaring to the startup section and now it's working. > > I still think it could be a good example to add in doc in the wiki. >> > > We put quite a bit of time into the Mojo > wiki<https://github.com/kraih/mojo/wiki#wiki-performance>recently on this > subject. Did you have a look at what's there? > I still think it would have help me to have an example of non-blocking http request that does not occurs in a controller section but inside of a running event loop like Mojo::IOLoop->recurring (there is no such example in the wiki). Now I'm thinking that such an example should not even be in the wiki as it has less to do with understanding the loop than understanding Mojo::IOLoop and Mojolicious as a whole. So I made a pull request to add a working example code for it. For now it's pending but you can find it here: https://github.com/13pass/mojo/blob/master/examples/non-blocking_agent_inside_loop.pl This may sound obvious for many Mojolicious devs but it's not. Still I'm no newbie regarding programming and using event loop and I did struggle a bit for this one. Now I'm thinking that some real novice may not be able to reproduce it easily and may decide to use Node.js instead. -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/groups/opt_out.
