diff options
| author | Shulhan <ms@kilabit.info> | 2024-10-30 23:24:07 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-10-30 23:24:07 +0700 |
| commit | 20fdd17d5202a356f1581345e73c15eb8ce1a42a (patch) | |
| tree | c29205534a9fef6cc4e5983affa6302c73269965 | |
| parent | 522a6765c9c3768e199344d2a26efe6f7e7db33e (diff) | |
| download | pakakeh.go-20fdd17d5202a356f1581345e73c15eb8ce1a42a.tar.xz | |
lib/play: expose the Timeout variable
By exposing the Timeout, user can set their maximum time the program
can run in their playground.
| -rw-r--r-- | lib/play/command.go | 4 | ||||
| -rw-r--r-- | lib/play/play.go | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/play/command.go b/lib/play/command.go index 2cbed88e..f3812dbe 100644 --- a/lib/play/command.go +++ b/lib/play/command.go @@ -23,14 +23,12 @@ type command struct { } func newCommand(req *Request, workingDir string) (cmd *command, err error) { - const defCommandTimeout = 30 * time.Second - cmd = &command{ buf: &bytes.Buffer{}, pid: make(chan int, 1), } var ctxParent = context.Background() - cmd.ctx, cmd.ctxCancel = context.WithTimeout(ctxParent, defCommandTimeout) + cmd.ctx, cmd.ctxCancel = context.WithTimeout(ctxParent, Timeout) var userHomeDir string diff --git a/lib/play/play.go b/lib/play/play.go index 6ea179c5..6abd79a8 100644 --- a/lib/play/play.go +++ b/lib/play/play.go @@ -50,6 +50,10 @@ import ( // code. var GoVersion = `1.23.2` +// Timeout define the maximum time the program can be run until it get +// terminated. +var Timeout = 10 * time.Second + var gomodTemplate = ` module play.local |
