mirror of
https://github.com/openai/codex.git
synced 2026-04-28 02:11:08 +03:00
adding exit signal
This commit is contained in:
@@ -805,6 +805,24 @@ async fn submission_loop(
|
||||
}
|
||||
});
|
||||
}
|
||||
Op::FlushRollout => {
|
||||
// Best-effort flush: shutdown recorder and ack so caller can wait.
|
||||
if let Some(sess_arc) = sess.as_ref() {
|
||||
let rec_opt = { sess_arc.rollout.lock().unwrap().as_ref().cloned() };
|
||||
if let Some(rec) = rec_opt {
|
||||
if let Err(e) = rec.shutdown().await {
|
||||
warn!("failed to flush rollout recorder: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
let event = Event {
|
||||
id: sub.id,
|
||||
msg: EventMsg::BackgroundEvent(BackgroundEventEvent {
|
||||
message: "rollout_flushed".to_string(),
|
||||
}),
|
||||
};
|
||||
tx_event.send(event).await.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,9 @@ pub enum Op {
|
||||
|
||||
/// Request a single history entry identified by `log_id` + `offset`.
|
||||
GetHistoryEntryRequest { offset: usize, log_id: u64 },
|
||||
|
||||
/// Flush and persist any pending rollout items (testing / graceful shutdown aid).
|
||||
FlushRollout,
|
||||
}
|
||||
|
||||
/// Determines the conditions under which the user is consulted to approve
|
||||
|
||||
@@ -232,6 +232,13 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
||||
event_processor.process_event(event);
|
||||
if is_last_event {
|
||||
handle_last_message(last_assistant_message, last_message_file.as_deref())?;
|
||||
// After task completes, flush rollout so external tests can observe all entries.
|
||||
let flush_id = codex.submit(Op::FlushRollout).await?;
|
||||
while let Some(event) = rx.recv().await {
|
||||
if event.id == flush_id {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user