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

Handling failed runs #7

Open
rgbkrk opened this issue Sep 29, 2016 · 2 comments
Open

Handling failed runs #7

rgbkrk opened this issue Sep 29, 2016 · 2 comments

Comments

@rgbkrk
Copy link

rgbkrk commented Sep 29, 2016

I'm doing something where I'm running N spawn to see if a command is available in an environment. I want to collect results of only those spawned processes that return an exit code of 0. I don't want to let the error bubble up, so I end up doing the whole catch -> Observable.empty thing.

function ipyKernelCheck(env) {
  const executable = path.join(env.prefix, 'bin', 'python');
  return spawn(executable, ['-m', 'ipykernel', '--version'], { split: true })
    .filter(x => x.source && x.source === 'stdout')
    .mapTo(env)
    .catch(err => Rx.Observable.empty());
}

If I could use the return code and squash the error I could. Should I fix something with my approach here or is there something worth exposing in spawn-rx?

@anaisbetts
Copy link
Owner

I think the catch is fine, I don't think it's a good idea to add a like, ignoreFailures parameter or something

@anaisbetts
Copy link
Owner

anaisbetts commented Sep 29, 2016

If you wanted to aggregate it you could do something like:

commandsToExecute
  .map({cmd, params} => spawn(cmd, params)
    .reduce((acc,x) => acc += x, '')
    .catch(() => Observable.empty()))
  .mergeAll(4 /* at a time */);

(coding via text area, not actually tested 😄 )

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

2 participants