tokio 1.0: delay -> sleep
almost the same thing, new name(s), no longer Unpin Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
427d90e6c1
commit
0a8d773ad0
@ -41,7 +41,7 @@ pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
if proxmox_backup::server::worker_is_active_local(&upid) {
|
if proxmox_backup::server::worker_is_active_local(&upid) {
|
||||||
tokio::time::delay_for(sleep_duration).await;
|
tokio::time::sleep(sleep_duration).await;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ async fn run_task_scheduler() {
|
|||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("task scheduler: compute next minute failed - {}", err);
|
eprintln!("task scheduler: compute next minute failed - {}", err);
|
||||||
tokio::time::delay_until(tokio::time::Instant::from_std(Instant::now() + Duration::from_secs(60))).await;
|
tokio::time::sleep_until(tokio::time::Instant::from_std(Instant::now() + Duration::from_secs(60))).await;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -286,7 +286,7 @@ async fn run_task_scheduler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::time::delay_until(tokio::time::Instant::from_std(delay_target)).await;
|
tokio::time::sleep_until(tokio::time::Instant::from_std(delay_target)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,7 +649,7 @@ async fn run_stat_generator() {
|
|||||||
|
|
||||||
generate_host_stats(save).await;
|
generate_host_stats(save).await;
|
||||||
|
|
||||||
tokio::time::delay_until(tokio::time::Instant::from_std(delay_target)).await;
|
tokio::time::sleep_until(tokio::time::Instant::from_std(delay_target)).await;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
|
|||||||
if !proxmox_backup::server::worker_is_active_local(&upid) {
|
if !proxmox_backup::server::worker_is_active_local(&upid) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tokio::time::delay_for(sleep_duration).await;
|
tokio::time::sleep(sleep_duration).await;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
if worker_is_active_local(&upid) {
|
if worker_is_active_local(&upid) {
|
||||||
tokio::time::delay_for(sleep_duration).await;
|
tokio::time::sleep(sleep_duration).await;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ impl HttpClient {
|
|||||||
|
|
||||||
let renewal_future = async move {
|
let renewal_future = async move {
|
||||||
loop {
|
loop {
|
||||||
tokio::time::delay_for(Duration::new(60*15, 0)).await; // 15 minutes
|
tokio::time::sleep(Duration::new(60*15, 0)).await; // 15 minutes
|
||||||
let (auth_id, ticket) = {
|
let (auth_id, ticket) = {
|
||||||
let authinfo = auth2.read().unwrap().clone();
|
let authinfo = auth2.read().unwrap().clone();
|
||||||
(authinfo.auth_id, authinfo.ticket)
|
(authinfo.auth_id, authinfo.ticket)
|
||||||
|
@ -385,7 +385,7 @@ pub async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHasher +
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
if let Some(httperr) = err.downcast_ref::<HttpError>() {
|
if let Some(httperr) = err.downcast_ref::<HttpError>() {
|
||||||
if httperr.code == StatusCode::UNAUTHORIZED {
|
if httperr.code == StatusCode::UNAUTHORIZED {
|
||||||
tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
|
tokio::time::sleep_until(Instant::from_std(delay_unauth_time)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(formatter.format_error)(err)
|
(formatter.format_error)(err)
|
||||||
@ -708,7 +708,7 @@ async fn handle_request(
|
|||||||
|
|
||||||
// always delay unauthorized calls by 3 seconds (from start of request)
|
// always delay unauthorized calls by 3 seconds (from start of request)
|
||||||
let err = http_err!(UNAUTHORIZED, "authentication failed - {}", err);
|
let err = http_err!(UNAUTHORIZED, "authentication failed - {}", err);
|
||||||
tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
|
tokio::time::sleep_until(Instant::from_std(delay_unauth_time)).await;
|
||||||
return Ok((formatter.format_error)(err));
|
return Ok((formatter.format_error)(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ async fn handle_request(
|
|||||||
let auth_id = rpcenv.get_auth_id();
|
let auth_id = rpcenv.get_auth_id();
|
||||||
if !check_api_permission(api_method.access.permission, auth_id.as_deref(), &uri_param, user_info.as_ref()) {
|
if !check_api_permission(api_method.access.permission, auth_id.as_deref(), &uri_param, user_info.as_ref()) {
|
||||||
let err = http_err!(FORBIDDEN, "permission check failed");
|
let err = http_err!(FORBIDDEN, "permission check failed");
|
||||||
tokio::time::delay_until(Instant::from_std(access_forbidden_time)).await;
|
tokio::time::sleep_until(Instant::from_std(access_forbidden_time)).await;
|
||||||
return Ok((formatter.format_error)(err));
|
return Ok((formatter.format_error)(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ async fn handle_request(
|
|||||||
return Ok(get_index(Some(userid.clone()), Some(new_csrf_token), language, &api, parts));
|
return Ok(get_index(Some(userid.clone()), Some(new_csrf_token), language, &api, parts));
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
tokio::time::delay_until(Instant::from_std(delay_unauth_time)).await;
|
tokio::time::sleep_until(Instant::from_std(delay_unauth_time)).await;
|
||||||
return Ok(get_index(None, None, language, &api, parts));
|
return Ok(get_index(None, None, language, &api, parts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,17 +331,17 @@ async fn get_service_state(service: &str) -> Result<String, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_service_is_state(service: &str, state: &str) -> Result<(), Error> {
|
async fn wait_service_is_state(service: &str, state: &str) -> Result<(), Error> {
|
||||||
tokio::time::delay_for(std::time::Duration::new(1, 0)).await;
|
tokio::time::sleep(std::time::Duration::new(1, 0)).await;
|
||||||
while get_service_state(service).await? != state {
|
while get_service_state(service).await? != state {
|
||||||
tokio::time::delay_for(std::time::Duration::new(5, 0)).await;
|
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn wait_service_is_not_state(service: &str, state: &str) -> Result<(), Error> {
|
async fn wait_service_is_not_state(service: &str, state: &str) -> Result<(), Error> {
|
||||||
tokio::time::delay_for(std::time::Duration::new(1, 0)).await;
|
tokio::time::sleep(std::time::Duration::new(1, 0)).await;
|
||||||
while get_service_state(service).await? == state {
|
while get_service_state(service).await? == state {
|
||||||
tokio::time::delay_for(std::time::Duration::new(5, 0)).await;
|
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user