mirror of
https://github.com/tendermint/tendermint.git
synced 2026-10-01 04:05:45 +00:00
+5
-1
@@ -2,6 +2,7 @@ package async
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
@@ -143,7 +144,10 @@ func Parallel(tasks ...Task) (trs *TaskResultSet, ok bool) {
|
||||
if pnk := recover(); pnk != nil {
|
||||
atomic.AddInt32(numPanics, 1)
|
||||
// Send panic to taskResultCh.
|
||||
taskResultCh <- TaskResult{nil, fmt.Errorf("panic in task %v", pnk)}
|
||||
const size = 64 << 10
|
||||
buf := make([]byte, size)
|
||||
buf = buf[:runtime.Stack(buf, false)]
|
||||
taskResultCh <- TaskResult{nil, fmt.Errorf("panic in task %v : %s", pnk, buf)}
|
||||
// Closing taskResultCh lets trs.Wait() work.
|
||||
close(taskResultCh)
|
||||
// Decrement waitgroup.
|
||||
|
||||
@@ -139,7 +139,7 @@ func checkResult(t *testing.T, taskResultSet *TaskResultSet, index int,
|
||||
case err != nil:
|
||||
assert.Equal(t, err.Error(), taskResult.Error.Error(), taskName)
|
||||
case pnk != nil:
|
||||
assert.Equal(t, pnk, taskResult.Error.Error(), taskName)
|
||||
assert.Contains(t, taskResult.Error.Error(), pnk, taskName)
|
||||
default:
|
||||
assert.Nil(t, taskResult.Error, taskName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user