-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout argument for run() #716
Comments
From def run(self, command: str, *args: str, **kwargs: Any) -> CommandResult:
raise NotImplementedError So you can pass whatever parameter you want to @martinhoyer do you want all backends support def run(self, command: str, timeout: int, *args: str, **kwargs: Any) -> CommandResult ? |
@amaslenn Thanks for looking into it.
The *args are being used to construct the actual command being run if I understand it correctly. |
@martinhoyer so you need only in - def run_local(self, command: str, *args: str) -> CommandResult:
+ def run_local(
+ self, command: str, *args: str, timeout: Optional[float] = None
+ ) -> CommandResult:
...
- stdout, stderr = p.communicate()
+ stdout, stderr = p.communicate(timeout=timeout) But will that do what you need? Backends like Ansible or SSH are using this function, but they won't pass timeout arg automatically, so changes in backends will also be needed. Overall interface might become unpredictable. Yet @philpep what do you think, would such change make sense? |
@amaslenn well, personally, I'm only using local for now, but I do realize that it would should be implemented in other backends, as mentioned in comment 0. If it's not as straightforward to implement there, then we can survive without it :) SSH though should have a same "communicate" timeout argument at least afaik. |
SSH is slightly different, it uses But anyway, this looks like a very useful feature. Yet maybe to keep the existing interface, |
I see, it's running ssh commands directly. You can just pass it to run_local there as well then. |
Would it make sense to add an optional
timeout
argument to host.run?In run_local it could be passed to
p.communicate()
and I imagine the other backends would have similar way to specify timeout.Sorry if I'm missing something, I'm new to testinfra.
The text was updated successfully, but these errors were encountered: