fix bug
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user