• Kirill Smelkov's avatar
    go: Don't allow leaked goroutines to prevent program to exit · 69cef96e
    Kirill Smelkov authored
    This is the Go behaviour, as demonstratd by the following program:
    
    ---- 8< ----
    package main
    
    import (
    	"fmt"
    	"time"
    )
    
    func work(w int) {
    	for i := 0; ; i++ {
    		fmt.Printf("w%d: %d\n", w, i)
    		time.Sleep(1*time.Second)
    	}
    }
    
    func main() {
    	for i := 0; i < 100; i++ {
    		go work(i)
    	}
    
    	time.Sleep(3*time.Second)
    	println("main: exit")
    }
    ---- 8< ----
    69cef96e
golang_test_goleaked.py 1.96 KB