Unverified Commit 65fe60f0 authored by Xin.Zh's avatar Xin.Zh Committed by GitHub

Merge pull request #32 from dk-lockdown/dev_1105

optimization:enhance robustness
parents 3cf58709 d02efaca
......@@ -21,8 +21,11 @@ import (
"fmt"
"log"
"math/rand"
"os"
"runtime/debug"
"sync"
"sync/atomic"
"time"
)
import (
......@@ -171,7 +174,15 @@ func (p *TaskPool) run(id int, q chan task) error {
case t, ok = <-q:
if ok {
t()
func() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "%s goroutine panic: %v\n%s\n",
time.Now(), r, string(debug.Stack()))
}
}()
t()
}()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment