matklad / xshell

Apache License 2.0
696 stars 30 forks source link

Add support for asynchronous execution #91

Closed Binlogo closed 4 months ago

Binlogo commented 4 months ago

This PR introduces asynchronous execution support.

Motivation

Sometimes, we'd like to run a command with a timeout, if the command stuck, user can be aware of it.

Proposal

Change

Relative issue

May move #76 forward?

matklad commented 4 months ago

I'd be against adding any kind of async runtime dependncy for this crate, even under a feature.

async xshell would be a useful crate. I can even see how it could be a better crate, as it'll allow you to easily spawn two tasks at the same time, and it'll also solve the "read stderr and stdout in lockstem" in much more elegant way. But that would be a different design, and it's best if it is worked on in a separate crate (btw, ashell name is free on crates.io ;). I'd gladly link to it from Readme, if it materializes.

At the same time, adding a timeout/deadline method, while preserving blocking API, would be great. I think it's OK to burn a thread just for that:

Binlogo commented 4 months ago

This xshell is an excellent crate for building xtask, which I enjoy and have grown accustomed to. Therefore, I tend to add more features and continue using it. Following your suggestion, I will close this PR and consider submitting a new one to introduce a timeout/deadline-specific extension without incorporating an async runtime.