Skip to content

Commit

Permalink
error checking on worker closes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmah42 committed May 31, 2022
1 parent 21b60c2 commit 9df83a2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/run/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ func bestWorker(ctx context.Context, ram uint64, addrs <-chan string) *internal.
if stat.FreeRam > ram {
if worker == nil || stat.FreeRam < bestFreeRam {
// Close out any worker we previously found
// TODO: error checking
if worker != nil {
worker.Close()
if err := worker.Close(); err != nil {
glog.Warningf("failed to close worker: %s", err)
}
}
worker = s
bestFreeRam = stat.FreeRam
Expand All @@ -91,8 +92,9 @@ func main() {
for i := 0; i < *retries; i++ {
// Close worker from previous attempt
if worker != nil {
// TODO: error checking
worker.Close()
if err := worker.Close(); err != nil {
glog.Warningf("failed to close worker: %s", err)
}
}
worker = bestWorker(ctx, *ram, addrs)
if worker == nil {
Expand Down

0 comments on commit 9df83a2

Please sign in to comment.