Skip to content

Commit

Permalink
fix(vmm): process message in a tokio thread to not block the current …
Browse files Browse the repository at this point in the history
…flow

Signed-off-by: Mateo Fernandez <[email protected]>
  • Loading branch information
mfernd committed May 30, 2024
1 parent 3914d4a commit aa80515
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/vmm/src/grpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,17 @@ impl VmmServiceTrait for VmmService {
let mut response_stream = client.execute(agent_request).await?;

// Process each message as it arrives
while let Some(response) = response_stream.message().await? {
let vmm_response = vmmorchestrator::ExecuteResponse {
stage: response.stage,
stdout: response.stdout,
stderr: response.stderr,
exit_code: response.exit_code,
};
tx.send(Ok(vmm_response)).await.unwrap();
}
tokio::spawn(async move {
while let Ok(Some(response)) = response_stream.message().await {
let vmm_response = vmmorchestrator::ExecuteResponse {
stage: response.stage,
stdout: response.stdout,
stderr: response.stderr,
exit_code: response.exit_code,
};
let _ = tx.send(Ok(vmm_response)).await;
}
});
}
Err(e) => {
error!("ERROR {:?}", e);
Expand Down

0 comments on commit aa80515

Please sign in to comment.