I have come across below code snippet under any request handler in "The Node Beginner Book" by Manuel Kiesling
My question is how right response object will be referenced in case of multiple concurrent request var exec = require("child_process").exec;
function start(response) {
console.log("Request handler 'start' was called.");
exec("ls -lah", function (error, stdout, stderr) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write(stdout);
response.end();
});
}
At T1, Request_1 and Request_2 arrives and calls exec() method. Both will separate child process and once done, will execute callback function.
My question is - As we are not passing response object as parameter to callback function, how callback will execute the right response method ?
via scott miles
No comments:
Post a Comment