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

Questions: run in parallel and stop #23

Closed
DavidMet opened this issue Oct 26, 2020 · 1 comment
Closed

Questions: run in parallel and stop #23

DavidMet opened this issue Oct 26, 2020 · 1 comment

Comments

@DavidMet
Copy link

DavidMet commented Oct 26, 2020

HI,

Few questions.

  1. Does each promise run in go routine ?
  2. in case each promise run in go-routine , is it possible to use timeout ?

e.g. in case you are running promise.all for promise A and promise B and you want to wait for 10 seconds for all the responses (time limit) ,but promise A continue to run (possible forever due to some issue), is it possible to kill promise A after the 10 seconds ? (when you want to get the results with the time limt)

Thanks!

@chebyrash
Copy link
Owner

chebyrash commented Oct 26, 2020

Hello

  1. Yes.

  2. Yes, you can implement your function to use context or use the time package (see example 1, example 2)
    When you say "kill" a promise I'm assuming forceful termination, and in that regard the answer is no. Go runtime does not provide a way to kill a specific goroutine.
    See this answer: question: is it possible to a goroutine immediately stop another goroutine? golang/go#32610 (comment)

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