-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Missing stdout line when process is waiting for input #4
Comments
Hello, and sorry about the delay, I unfortunately have a Monday deadline and am scribbling on that. And thanks for the good, clear bug report - I didn't even have to look at my code to know what was wrong, though I did validate it. It's my belief that it is actually "working as intended" except that "intended" in your use case has a less useful result for you. :-/
Unfortunately, I can't change the default behavior, but what I could do is this - to add an optional boolean flag that switches the behavior from "yielding complete lines" to "yielding what comes out as it comes out" by using partial reads instead of readlines in that code above. My feeling is unfortunately that it would be 15 minutes to write, and an hour to effectively test. My plan is to carefully make the change and make a new release with this "untested undocumented boolean flag" which you can then test and see if it fixes your problem or not. |
Bad news: I don't see a way to do it effectively. https://docs.python.org/3/library/asyncio-stream.html#streamreader claims to have a I'm going to have to put this on hold for a bit, let me know if you have any ideas. |
Hm... I'm not that good on low level stuff :/ maybe it is possible to yield either complete line or everything buffered (even without newline character) when the subprocess is waiting for some input somehow? Or disable buffering or something... |
One way to do this would be to read single characters at a time with a
timeout and then yield them. It would be somewhat slow, but that might be
literally nothing compared to the time you are spending in the subprocess
calling terraform!
I could write that fairly fast.
No matter what you do, this is going to be fragile. For example, if the
program you were calling removes that extra carriage return or add a new
one, everything will be thrown off.
…On Mon, Dec 12, 2022 at 10:37 AM mgzenitech ***@***.***> wrote:
Hm... I'm not that good on low level stuff :/ maybe it is possible to
yield either complete line *or* when the subprocess is waiting for some
input somehow? Or disable buffering or something...
—
Reply to this email directly, view it on GitHub
<#4 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB53MTHXYAPMV55EABJ6XTWM3W3XANCNFSM6AAAAAASZNPXXY>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
--
/t
PGP Key: ***@***.***
*https://tom.ritchford.com <https://tom.ritchford.com>*
*https://tom.swirly.com <https://tom.swirly.com>*
|
Well, I wasn't right. It really doesn't seem to be easy to do at all without going into lower level stuff, which isn't cross-platform, and I don't have the time and facilities to even start on that. There must be some other way to directly script terraform! |
I think Terraform is just an example here, but any app that requires input and does not print newline before that will be affected, no? Maybe it would be possible to create something up for at least unix based systems? |
So I added something that might actually do what you want. There's a new parameter I made a new release. Update, and then set Lemme know!! |
superb! Works as expected now! Thanks :) |
Aces!!!!!!! |
Minimal example to reproduce (running Terraform as a subprocess):
Output:
However we are missing one more line with input:
It appears however if I press enter afterwards
The text was updated successfully, but these errors were encountered: