Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing a handler after an async function has finnished it's parallel tasks #6

Closed
ghost opened this issue Dec 5, 2010 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 5, 2010

I have an async function that executes some shell commands in parallel

require("fs").readdir("./", function (error, folders) { // asynched
    require("underscore")._(folders).each(function (folder, folderKey, folderList) { // asynched
    r("child_process").exec("ls ./" + folder, function(error, stdout, stderr) {
           console.log("Cant put it here") // Will be run after the first execution is completed
        })
        console.log("Cant put it here either") // Will be run immediately before any execution is completed
    })
    console.log("Cant put it here either") // Will be run immediately before any execution is completed
})

I want to do something after those shell commands are executed but I cant figure out how to do this with async library. Those shell commands are executed in parallel, so there is no way to register a handler that is executed after all of them are executed.

Any ideas?

@ghost
Copy link
Author

ghost commented Dec 5, 2010

A Stackoverflow question I posted for this issue: http://stackoverflow.com/questions/4357391/running-serial-operations-in-node-js

@caolan
Copy link
Owner

caolan commented Dec 5, 2010

I've posted a response on Stackoverflow, hope that helps.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant