-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Properly time out gp open
#20378
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
Properly time out gp open
#20378
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ var openCmd = &cobra.Command{ | |
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| // TODO(ak) use NotificationService.NotifyActive supervisor API instead | ||
|
|
||
| ctx, cancel := context.WithTimeout(cmd.Context(), 5*time.Second) | ||
| ctx, cancel := context.WithTimeout(cmd.Context(), 10*time.Second) | ||
| defer cancel() | ||
|
|
||
| client, err := supervisor.New(ctx) | ||
|
|
@@ -57,12 +57,23 @@ var openCmd = &cobra.Command{ | |
|
|
||
| if wait { | ||
| pargs = append(pargs, "--wait") | ||
| ctx = cmd.Context() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: there're (But the original code has this issue as well, so I'm not sure if this is an intended There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mustard-mh looking at the code again, it seems fine to use the timeout-enabled context everywhere besides the final call to the editor binary, since we want to be able to time out on the other operations that are not expected to run potentially indefinitely. Running the following inside the go run . open --wait main.go |
||
| } | ||
| c := exec.CommandContext(cmd.Context(), pcmd, append(pargs[1:], args...)...) | ||
| c := exec.CommandContext(ctx, pcmd, append(pargs[1:], args...)...) | ||
| c.Stdin = os.Stdin | ||
| c.Stdout = os.Stdout | ||
| c.Stderr = os.Stderr | ||
| return c.Run() | ||
| time.Sleep(10 * time.Second) | ||
filiptronicek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| err = c.Run() | ||
| if err != nil { | ||
| if ctx.Err() != nil { | ||
| return xerrors.Errorf("editor failed to open in time: %w", ctx.Err()) | ||
| } | ||
|
|
||
| return xerrors.Errorf("editor failed to open: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| }, | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.