fix: move sleep to only occur when recv returns empty, avoid message delivery delay
This commit is contained in:
parent
4ceae6cf67
commit
d99e0812d0
1 changed files with 7 additions and 2 deletions
|
|
@ -166,7 +166,13 @@ async fn serve(
|
|||
turn::emit_turn_end(&bus, &outcome);
|
||||
bus.set_state(TurnState::Idle);
|
||||
}
|
||||
Ok(AgentResponse::Empty) => {}
|
||||
Ok(AgentResponse::Empty) => {
|
||||
// Idle: brief sleep before next poll to avoid busy-looping
|
||||
// on consecutive Empty responses. The recv() call already
|
||||
// waits up to 180s for messages, so this is just for
|
||||
// responsiveness if recv() times out.
|
||||
tokio::time::sleep(interval).await;
|
||||
}
|
||||
Ok(AgentResponse::Ok
|
||||
| AgentResponse::Status { .. }
|
||||
| AgentResponse::Recent { .. }
|
||||
|
|
@ -180,7 +186,6 @@ async fn serve(
|
|||
tracing::warn!(error = ?e, "recv failed; retrying");
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(interval).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue