I have a piece of code in node js that takes a few seconds the finish so i started using threads_a_gogo module( https://github.com/xk/node-threads-a-gogo ) to not block http requests. I spent a lot of times trying to figure out why the threat spawn is not working because my requests are still blocked.
app.post('/results.html', function(req, res){ if( config.debug ) console.log("thread created"); var t = threads.create(); var r = new rounds(); t.eval( r.start(req,res), function(err, result) { r.finish( res ); //t.destroy(); if( config.debug ) console.log("thread destroyed"); }); console.log("request finished"); });
console.log("request finished"); is only displayed AFTER the new thread finish but it is suppose to show almost when the request is done and its blocking request to the server until the process finish.
Any idea about what im doing wrong?
Thx