-
Notifications
You must be signed in to change notification settings - Fork 384
Unblock subprocesses waiting for stdin close #553
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
Conversation
|
The appveyor seems to fail on many (all?) jobs with failing to find: |
| # When reading from file-like objects that aren't "real" | ||
| # terminal streams, an empty byte signals EOF. | ||
| if not self.using_pty: | ||
| self._close_proc_stdin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can check for the existence of attribute on self to allow subclasses to defer the fix
|
I'm a bit leery about the Can you provide more details about how the current test and implementation are both wrong? Thanks! |
|
Hi @bitprophet I have to run but had time to answer some of your concerns, I can cover the two usage locations of is_dead usage later if you need: Original code: New code: For new code, if a is "is_alive" and b is "self.exc_info is None", we can substitute and then rearrange for the Which is exactly the same as the original except using Consider the case where the thread completes normally, the thread's is_alive will be False, in the original code: Which means: The test case was implemented incorrectly to make it pass, here is one of them: The last line is asserting that the thread is alive, right after a thread join, |
|
i updated the tests for additional validation of underlying conditions, and the call to the new close stdin is now checked first to allow subclasses in other repos (fabric?) to update on it's own schedule I think we'll want to squash the commmits, kept separate for review purposes |
|
I didn't call it out here, but there is a minimal test scenario in #552 |
Partial fix for #552 BREAKING CHANGE FOR RUNNER IMPLEMENTATIONS: New method added close_proc_stdin to allow the parent Runner to ask subclass to close the stream after it finds the end of the stream. Fix ExceptionHandlingThread.is_dead which before would report dead when thread was not alive and there was no exception info This does not fix when pty=True, more significant changes are required for that case Two test cases were adjusted that were wrongly asserting that the thread should be "is_dead" after thread.join()
|
To make things more interesting, occassionally (maybe 1/4 of the time), I get an UnexpectedExit error in program.py:run (running the same task) when I have I don't know yet if it's something I introduced, or pointing to something deeper and darker. The Result is false, printing out the Result shows:
I think the process hasn't finished terminating / set the returncode, if i return poll() for returncode, I can't repro the issue . . not sure why we'd get past all the thread joins though while process is still alive though. |
|
This issue is making it impossible to write a task that feeds a string to the stdin when shelling out. I'm doing something along these lines: @task
def t(c):
input_string = ...
c.run("program --that waits/until/stdin/ends", in_stream=StringIO(input_string))The process just hangs forever, because the program won't do anything until stdin is exhausted. A really simple repro: from invoke import task
from io import StringIO
@task
def t(c):
c.run("cat", in_stream=StringIO("foo"))If you run this task, it should print 'foo' and then hang forever. I tried all manner of combinations of @bitprophet what needs to be done to get this PR merged? See also #575 (comment). |
|
I'm having the same issue as @seansfkelley — just trying to send dynamic input to a process using |
|
I never closed this when 1.3.0 came out - it includes fixes for this including potentially some cherry-picks. Should be fixed now. |
|
Still reproducible in |
Partial fix for #552
New method added _close_proc_stdin to allow the parent Runner to ask
subclass to close the stream after it finds the end of the stream. If the subclass
has not implemented _close_proc_stdin yet, then it is a no-op (and the bug
remains)
Fix ExceptionHandlingThread.is_dead which before would report dead when
thread was not alive and there was no exception info
This does not fix when pty=True, more significant changes are required for that case
Two test cases were adjusted that were wrongly asserting that the thread
should be "is_dead" after thread.join()