Skip to content

Commit

Permalink
🐛 fix logic of time limit
Browse files Browse the repository at this point in the history
  • Loading branch information
comavius committed Oct 6, 2024
1 parent 95cc8e4 commit 487f974
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion judge-control-app/src/remote_exec/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,15 @@ impl<AddrType: ToSocketAddrs> SshConnection<AddrType> {
Ok(output)
};
let timeout_future = async move {
let result = timeout(execution_time_limit, exec_future)
let start_time = tokio::time::Instant::now();
let result = timeout(execution_time_limit + Duration::from_secs(1), exec_future)
.await
.map_err(|e| anyhow::Error::from(e))
.context("Execution time limit exceeded")?;
let elapsed = tokio::time::Instant::now().duration_since(start_time);
if elapsed >= execution_time_limit {
return Err(anyhow::anyhow!("Execution time limit exceeded"));
}
result
};
let result: Result<String, RemoteServerError> = timeout_future
Expand Down

0 comments on commit 487f974

Please sign in to comment.