From e6821c54e23127d8447915af892f8b28de276e88 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Wed, 4 Feb 2026 00:31:10 +0800 Subject: [PATCH] fix bug --- internal/logic/strategy/boot.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/logic/strategy/boot.go b/internal/logic/strategy/boot.go index 5fbb075..da0e3b5 100644 --- a/internal/logic/strategy/boot.go +++ b/internal/logic/strategy/boot.go @@ -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()