repl: Check process status and propagate to output (#14782)

<img width="582" alt="image"
src="https://github.com/user-attachments/assets/14bd321d-f5fc-4cc0-9386-f435423057ad">

Release Notes:

- N/A
This commit is contained in:
Kyle Kelley 2024-07-18 19:35:05 -07:00 committed by GitHub
parent 5008a388e6
commit 48211e8ce2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 53 additions and 3 deletions

View file

@ -177,11 +177,62 @@ impl Session {
let kernel = kernel.await;
match kernel {
Ok((kernel, mut messages_rx)) => {
Ok((mut kernel, mut messages_rx)) => {
this.update(&mut cx, |this, cx| {
// At this point we can create a new kind of kernel that has the process and our long running background tasks
let status = kernel.process.status();
this.kernel = Kernel::RunningKernel(kernel);
cx.spawn(|session, mut cx| async move {
let error_message = match status.await {
Ok(status) => {
if status.success() {
log::info!("kernel process exited successfully");
return;
}
format!("kernel process exited with status: {:?}", status)
}
Err(err) => {
format!("kernel process exited with error: {:?}", err)
}
};
log::error!("{}", error_message);
session
.update(&mut cx, |session, cx| {
session.kernel =
Kernel::ErroredLaunch(error_message.clone());
session.blocks.values().for_each(|block| {
block.execution_view.update(
cx,
|execution_view, cx| {
match execution_view.status {
ExecutionStatus::Finished => {
// Do nothing when the output was good
}
_ => {
// All other cases, set the status to errored
execution_view.status =
ExecutionStatus::KernelErrored(
error_message.clone(),
)
}
}
cx.notify();
},
);
});
cx.notify();
})
.ok();
})
.detach();
this.messaging_task = cx.spawn(|session, mut cx| async move {
while let Some(message) = messages_rx.next().await {
session