You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let command_timeout = Duration::from_secs(300);// 5 minutes default
83
-
let result = tokio::time::timeout(
84
-
command_timeout,
85
-
client.execute(command)
86
-
)
87
-
.await
88
-
.with_context(|| format!("Command execution timeout: The command '{}' did not complete within 5 minutes on {}:{}", command,self.host,self.port))?
89
-
.with_context(|| format!("Failed to execute command '{}' on {}:{}. The SSH connection was successful but the command could not be executed.", command,self.host,self.port))?;
83
+
let result = ifletSome(timeout_secs) = timeout_seconds {
84
+
if timeout_secs == 0{
85
+
// No timeout (unlimited)
86
+
tracing::debug!("Executing command with no timeout (unlimited)");
87
+
client.execute(command)
88
+
.await
89
+
.with_context(|| format!("Failed to execute command '{}' on {}:{}. The SSH connection was successful but the command could not be executed.", command,self.host,self.port))?
90
+
}else{
91
+
// With timeout
92
+
let command_timeout = Duration::from_secs(timeout_secs);
93
+
tracing::debug!("Executing command with timeout of {} seconds", timeout_secs);
94
+
tokio::time::timeout(
95
+
command_timeout,
96
+
client.execute(command)
97
+
)
98
+
.await
99
+
.with_context(|| format!("Command execution timeout: The command '{}' did not complete within {} seconds on {}:{}", command, timeout_secs,self.host,self.port))?
100
+
.with_context(|| format!("Failed to execute command '{}' on {}:{}. The SSH connection was successful but the command could not be executed.", command,self.host,self.port))?
101
+
}
102
+
}else{
103
+
// Default timeout of 300 seconds if not specified
104
+
let command_timeout = Duration::from_secs(300);
105
+
tracing::debug!("Executing command with default timeout of 300 seconds");
106
+
tokio::time::timeout(
107
+
command_timeout,
108
+
client.execute(command)
109
+
)
110
+
.await
111
+
.with_context(|| format!("Command execution timeout: The command '{}' did not complete within 5 minutes on {}:{}", command,self.host,self.port))?
112
+
.with_context(|| format!("Failed to execute command '{}' on {}:{}. The SSH connection was successful but the command could not be executed.", command,self.host,self.port))?
0 commit comments