mirror of
https://github.com/openai/codex.git
synced 2026-04-28 02:11:08 +03:00
blocking
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Result;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -447,16 +447,6 @@ fn bind_server(port: u16) -> io::Result<Server> {
|
||||
const MAX_ATTEMPTS: u32 = 10;
|
||||
const RETRY_DELAY: Duration = Duration::from_millis(200);
|
||||
|
||||
fn retry_sleep(delay: Duration) {
|
||||
if tokio::runtime::Handle::try_current().is_ok() {
|
||||
let _ = tokio::task::block_in_place(|| {
|
||||
std::thread::sleep(delay);
|
||||
});
|
||||
} else {
|
||||
std::thread::sleep(delay);
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
match Server::http(&bind_address) {
|
||||
Ok(server) => return Ok(server),
|
||||
@@ -477,7 +467,7 @@ fn bind_server(port: u16) -> io::Result<Server> {
|
||||
}
|
||||
}
|
||||
|
||||
retry_sleep(RETRY_DELAY);
|
||||
thread::sleep(RETRY_DELAY);
|
||||
|
||||
if attempts >= MAX_ATTEMPTS {
|
||||
return Err(io::Error::new(
|
||||
|
||||
Reference in New Issue
Block a user