mirror of https://github.com/panjf2000/ants.git
opt: use runtime/debug.Stack() to print stack trace of panic
This commit is contained in:
parent
3110e41921
commit
7a56a5c082
|
@ -23,7 +23,7 @@
|
||||||
package ants
|
package ants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,10 +53,7 @@ func (w *goWorker) run() {
|
||||||
if ph := w.pool.options.PanicHandler; ph != nil {
|
if ph := w.pool.options.PanicHandler; ph != nil {
|
||||||
ph(p)
|
ph(p)
|
||||||
} else {
|
} else {
|
||||||
w.pool.options.Logger.Printf("worker exits from a panic: %v\n", p)
|
w.pool.options.Logger.Printf("worker exits from panic: %v\n%s\n", p, debug.Stack())
|
||||||
var buf [4096]byte
|
|
||||||
n := runtime.Stack(buf[:], false)
|
|
||||||
w.pool.options.Logger.Printf("worker exits from panic: %s\n", string(buf[:n]))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Call Signal() here in case there are goroutines waiting for available workers.
|
// Call Signal() here in case there are goroutines waiting for available workers.
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
package ants
|
package ants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,10 +53,7 @@ func (w *goWorkerWithFunc) run() {
|
||||||
if ph := w.pool.options.PanicHandler; ph != nil {
|
if ph := w.pool.options.PanicHandler; ph != nil {
|
||||||
ph(p)
|
ph(p)
|
||||||
} else {
|
} else {
|
||||||
w.pool.options.Logger.Printf("worker with func exits from a panic: %v\n", p)
|
w.pool.options.Logger.Printf("worker exits from panic: %v\n%s\n", p, debug.Stack())
|
||||||
var buf [4096]byte
|
|
||||||
n := runtime.Stack(buf[:], false)
|
|
||||||
w.pool.options.Logger.Printf("worker with func exits from panic: %s\n", string(buf[:n]))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Call Signal() here in case there are goroutines waiting for available workers.
|
// Call Signal() here in case there are goroutines waiting for available workers.
|
||||||
|
|
Loading…
Reference in New Issue