Skip to content
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

Need way for await sh.command to return RunningCommand #743

Closed
hartmans opened this issue Jan 7, 2025 · 2 comments · Fixed by #744
Closed

Need way for await sh.command to return RunningCommand #743

hartmans opened this issue Jan 7, 2025 · 2 comments · Fixed by #744

Comments

@hartmans
Copy link
Contributor

hartmans commented Jan 7, 2025

I'm finally porting Carthage from sh 1.x to sh 2.x. We had our own hack to enable async for sh, and we had a lot of code that did things like

result = await sh.ssh(...)

And then for example looked at result.stdout.
So, part of this can be handled by setting _return_cmd=True, but the definition of RunningCommand.__await__ is hard-coded to return str(self).
Obviously, I can do something like

result = sh.ssh(...)
await result

But that feels clumsy.
I'd like a kwarg that returns a RunningCommand even on async await.
My preference would be to try and convince you that _return_cmd should affect await as well as call, but if you are concerned about the API instability, I'm happy with anything that I can pass into bake.

Thanks for your consideration.

@amoffat
Copy link
Owner

amoffat commented Jan 7, 2025

I think that's a reasonable request, and the way the api should work. The fact that it doesn't seems to be incorrect behavior. Do you feel comfortable making this change?

@hartmans
Copy link
Contributor Author

hartmans commented Jan 7, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants