fix querytest timeout
This commit is contained in:
parent
c702894f64
commit
1638baf604
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"qnc-server/common/xerr"
|
"qnc-server/common/xerr"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@ -37,7 +38,13 @@ func (l *QuerySingleTestLogic) QuerySingleTest(req *types.QuerySingleTestReq) (r
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "单查测试, 序列化参数失败 : %d", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "单查测试, 序列化参数失败 : %d", err)
|
||||||
}
|
}
|
||||||
apiResp, err := l.svcCtx.ApiRequestService.PreprocessRequestApi(l.ctx, marshalParams, req.Api)
|
|
||||||
|
// 创建一个30分钟超时的上下文
|
||||||
|
timeoutCtx, cancel := context.WithTimeout(l.ctx, 30*time.Minute)
|
||||||
|
defer cancel() // 确保在函数返回时取消上下文,防止资源泄漏
|
||||||
|
|
||||||
|
// 使用新的超时上下文
|
||||||
|
apiResp, err := l.svcCtx.ApiRequestService.PreprocessRequestApi(timeoutCtx, marshalParams, req.Api)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "单查测试, 获取接口失败 : %d", err)
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "单查测试, 获取接口失败 : %d", err)
|
||||||
}
|
}
|
||||||
|
BIN
tmp/main.exe
BIN
tmp/main.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user