加线程delay
This commit is contained in:
@@ -624,6 +624,7 @@ func (c *Crawler) Run(entryURL string, maxEpoch int) {
|
|||||||
cs.IsRunning = false
|
cs.IsRunning = false
|
||||||
})
|
})
|
||||||
// 空循环等 normalChildCh,新数据到达后立即从 epoch 0 重新开始
|
// 空循环等 normalChildCh,新数据到达后立即从 epoch 0 重新开始
|
||||||
|
// 加 1000ms 睡眠避免 CPU 空转轮询
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case gc, ok := <-c.normalChildCh:
|
case gc, ok := <-c.normalChildCh:
|
||||||
@@ -641,6 +642,8 @@ func (c *Crawler) Run(entryURL string, maxEpoch int) {
|
|||||||
case <-c.stopCh:
|
case <-c.stopCh:
|
||||||
// 收到停止信号
|
// 收到停止信号
|
||||||
return
|
return
|
||||||
|
case <-time.After(1000 * time.Millisecond):
|
||||||
|
// 每 1000ms 检查一次,降低 CPU 占用
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
restartEpochLoop:
|
restartEpochLoop:
|
||||||
|
|||||||
+1
-1
Submodule sese-engine-ui updated: 52c1b9de99...60e897f110
Reference in New Issue
Block a user