mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
fix(loop): polling (#2103)
This commit is contained in:
+8
-5
@@ -387,10 +387,17 @@ func (al *AgentLoop) Run(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for al.running.Load() {
|
||||
idleTicker := time.NewTicker(100 * time.Millisecond)
|
||||
defer idleTicker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-idleTicker.C:
|
||||
if !al.running.Load() {
|
||||
return nil
|
||||
}
|
||||
case msg, ok := <-al.bus.InboundChan():
|
||||
if !ok {
|
||||
return nil
|
||||
@@ -517,12 +524,8 @@ func (al *AgentLoop) Run(ctx context.Context) error {
|
||||
al.publishResponseIfNeeded(ctx, target.Channel, target.ChatID, finalResponse)
|
||||
}
|
||||
}()
|
||||
default:
|
||||
time.Sleep(time.Microsecond * 200)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// drainBusToSteering consumes inbound messages and redirects messages from the
|
||||
|
||||
Reference in New Issue
Block a user