This commit is contained in:
yanweidong
2026-02-04 00:31:10 +08:00
parent 8e1b05fb42
commit e6821c54e2

View File

@@ -19,11 +19,20 @@ func BootAiStart(key string, ymd int) {
panic(err)
}
var wg sync.WaitGroup
// Create a buffered channel with a capacity of 20 to act as a semaphore
semaphore := make(chan struct{}, 20)
var wg sync.WaitGroup
for _, row := range datas {
wg.Add(1)
go BootAiTask(row.ID, row.Code, &wg)
// Acquire a slot in the semaphore
semaphore <- struct{}{}
go func(row models.StratModel) {
defer wg.Done()
// Release the slot in the semaphore when done
defer func() { <-semaphore }()
BootAiTask(row.ID, row.Code, &wg)
}(row)
}
wg.Wait()