Comments (9)
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. :-/
sproc
's code doesn't decide when a line ending happens - that is left up to Python's I/O system, right here.
Unfortunately, input()
doesn't send a line ending typically, and so Python doesn't send me the line until after the input has taken in the value, just as you report.
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.
from sproc.
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 readuntil
method, but I don't see it a way to use it in practice, because of the buffering that hides this.
I'm going to have to put this on hold for a bit, let me know if you have any ideas.
from sproc.
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...
from sproc.
from sproc.
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!
from sproc.
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?
from sproc.
So I added something that might actually do what you want.
There's a new parameter by_lines
to sproc.Sub
that's set to True
by default. If you set it to False
you get everything in one call to the underlying stream: https://docs.python.org/3/library/io.html#io.BufferedReader.read1
I made a new release. Update, and then set sproc.Sub(..., by_lines=False)
.
Lemme know!!
from sproc.
superb! Works as expected now! Thanks :)
from sproc.
Aces!!!!!!!
from sproc.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sproc.