Closed lgarrison closed 2 years ago
Hello @lgarrison! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Corrfunc/utils.py
:Line 1032:80: E501 line too long (84 > 79 characters) Line 1033:80: E501 line too long (83 > 79 characters) Line 1034:80: E501 line too long (86 > 79 characters) Line 1035:80: E501 line too long (84 > 79 characters) Line 1036:80: E501 line too long (82 > 79 characters) Line 1037:80: E501 line too long (83 > 79 characters) Line 1049:1: W293 blank line contains whitespace
I still do not understand why this works (well, really why there is a bug in the first place). @lgarrison Do you think this is okay to merge?
Interestingly, both of the following commands now hang for me, while previously only the second one did:
$ python repro.py 2> eout.txt
$ python -u repro.py 2> eout.txt
Something about my environment has probably changed since I first looked into this issue (I did check that PYTHONUNBUFFERED
is not set).
But in any case, the fix remains valid, if only for the reason that it avoids invoking Wurlitzer in a scenario Wurlitzer tells us it cannot handle. So this is ready for merge.
Great - merged!
From #269, invoking a Corrfunc script as
python -u script.py &> out.txt
causes the script to hang. Something about the combination of redirection and unbuffered output was causing trouble. This change adds an additional check,sys.stdout is sys.__stdout__
, to see if Python'ssys.stdout
has been redirected elsewhere, like a Jupyter cell, in which case we want to follow that redirect. Otherwise, we don't touch anything.I don't exactly understand why unbuffered output causes a problem when buffered output did not, but I'm pretty confident that this new check more accurately reflects the scenarios in which we actually want redirection. This new check probably supersedes the
sys.stdout.isatty()
check, but to be conservative, we'll keep both.Minimal reproducer, note it is completely unrelated to Corrfunc:
This probably reflects my ignorance around pipes and fd's more than anything else!