-
Notifications
You must be signed in to change notification settings - Fork 399
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
Build should take a context.Context #80
Comments
Hi @jonjohnsonjr Can I take this? |
Sure! |
@jonjohnsonjr I have a question. Does this refer to the private method |
The public method, but I suspect we'll have to change both so that we can use https://godoc.org/os/exec#CommandContext |
Does that mean we will take another flag argument for the timeout duration? Because I was thinking something along the line of |
I don't think we need a timeout. Truth be told, I don't use contexts for cancellation much, so I'm not sure what the idiomatic way to do this would be. My thinking was similar to yours (for I stumbled across https://github.com/buildpack/pack/blob/9306cf3e129977b57d1ee8d57a1c1ac814a66898/commands/commands.go#L50-L61 when poking around in the buildpacks project, which seems similar to what we want, but again there might be a better way. |
I was thinking of simply localizing it to the private signals := make(chan os.Signal)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
ctx, cancel := context.WithCancel(context.Background())
go func() {
<-signals
cancel()
}()
cmd := exec.CommandContext(ctx, "go", args...) Reason being that |
My thinking here was specifically for external packages. Before cutting a 1.0 release, I thought we'd want to add a context to the API, since I might be misunderstanding the purpose of context, though. I see that it's usually request oriented?
I think that's fine for I appreciate the back and forth here -- I'm not entirely sure what the best path forward here is, so any other ideas are helpful. |
@jonjohnsonjr Ohhh u're right about that. I didn't think of using |
Yeah that sounds great! Hopefully it's not too much trouble :) |
Fixed by #105 |
Builds can take a while, so it would be nice to be able to cancel them.
The text was updated successfully, but these errors were encountered: