Skip to content

Commit 0258f57

Browse files
committed
fix(repo): 超时 5 秒,请求失败时返回空
1 parent c9f67da commit 0258f57

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

laravel/app/Http/Repository/MultithreadingRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function newLoadExcel()
253253
*/
254254
public function newRequest($url, $appkey)
255255
{
256-
$client = new Client();
256+
$client = new Client(['timeout' => 5]);
257257
// 简单本地并发的 GET 请求测试
258258
$requests = function($url, $appkey, $dataSet) use ($client) {
259259
$newParam = [];
@@ -304,7 +304,7 @@ public function newRequest($url, $appkey)
304304
'rejected' => function($reason, $index) {
305305
// this is delivered each failed request
306306
Log::error('request-failed: ID-'.$index, ['reason' => $reason]);
307-
$this->data[$index] = [];
307+
$this->data[$index] = '';
308308
//return 'Index: '.$index.' Reason:'.$reason;
309309
},
310310
]);

0 commit comments

Comments
 (0)