Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Unblock subprocesses waiting for stdin close #553
Partial fix for #552
New method added _close_proc_stdin to allow the parent Runner to ask
Fix ExceptionHandlingThread.is_dead which before would report dead when
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
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:
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:
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
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).