Merge pull request #232 from wagoodman/mysterious-hello-world-167

add sleep to prevent termbox race condition
This commit is contained in:
Alex Goodman 2019-09-23 22:09:30 -04:00 committed by GitHub
commit 07af6d785b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ import (
"io/ioutil"
"log"
"os"
"time"
"github.com/dustin/go-humanize"
"github.com/wagoodman/dive/dive/filetree"
@ -113,6 +114,13 @@ func Run(options Options) {
cache := filetree.NewFileTreeCache(result.RefTrees)
cache.Build()
// it appears there is a race condition where termbox.Init() will
// block nearly indefinitely when running as the first process in
// a Docker container when started within ~25ms of container startup.
// I can't seem to determine the exact root cause, however, a large
// enough sleep will prevent this behavior (todo: remove this hack)
time.Sleep(100 * time.Millisecond)
ui.Run(result, cache)
}
}