rexpect icon indicating copy to clipboard operation
rexpect copied to clipboard

Configurable sleeps

Open zmitchell opened this issue 1 year ago • 6 comments

Hi, I was integrating rexpect into a project and found that the sleeps are longer than what we needed. Specifically the sleep in read_until is 100ms, and I found that decreasing this to 5ms sped up some of our tests that are using rexpect.

https://github.com/rust-cli/rexpect/blob/be7f1ab8147c3c17e0600e59d1f98d1963d2d880/src/reader.rs#L287

Of course I wouldn't suggest everyone using 5ms, so maybe there's room for configurability? For now I have a fork with that small change.

zmitchell avatar Feb 18 '25 18:02 zmitchell

We already have a timeout, this is just the sleep to yield the thread within that timeout. We should probably make the sleep dependent on the timeout so we don't sleep longer than it.

I'm open to ideas of how we should calculate the sleep.

epage avatar Feb 18 '25 18:02 epage

If I understand correctly this are two different times though in the sense that if I receive the output I'm looking for 1ms after the first run of the loop I need to wait 100ms to find out, and I incur that 100ms for each back and forth with the shell. This adds up pretty quickly in a test scenario where an rexpect-using test can take multiples of 100ms whereas other tests may take 10ms. That's more my concern.

zmitchell avatar Feb 18 '25 19:02 zmitchell

So if I'm understanding correctly, you don't want to change the timeout, just how long until the process wakes up for it to check if its done, making this closer to a busy loop?

epage avatar Feb 18 '25 19:02 epage

Yes, but I want to be able to make that choice for myself. I think there are totally valid reasons that not everyone would want something closer to a busy loop.

zmitchell avatar Feb 19 '25 07:02 zmitchell

Seems reasonable. Thanks for taking the time to clarify the request!

epage avatar Feb 19 '25 17:02 epage

Hey team, about this issue, does @zmitchell work on it, or could I jump-in and work on it from my side?

peterman42 avatar Mar 29 '25 22:03 peterman42