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

Python 3 fixes - fix process_handler timing out #6232

Merged
merged 2 commits into from Jul 25, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Jul 25, 2018

Problem

Process_handler was timing out on Py3.

@Eric-Arellano Eric-Arellano changed the title Python 3 fixes - fix process_handler timing out (WIP) Python 3 fixes - fix process_handler timing out Jul 25, 2018

@@ -106,8 +106,8 @@ def join_and_get_output():

def _tee(infile, outfile, return_function):
accumulator = io.BytesIO()
for line in iter(infile.readline, ""):
for line in iter(infile.readline, b""):

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Jul 25, 2018

Contributor

This was causing iter to never stop, because in Py3 it couldn't find the unicode "", only bytes "". Py2 doesn't care because it allows either or.

Thanks @illicitonion for the find!

accumulator.write(line)
outfile.write(line)
outfile.buffer.write(line) if PY3 else outfile.write(line)

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Jul 25, 2018

Contributor

In Py2, streams like stdin write directly using bytes. In Py3, they write using unicode, and if you want to use bytes you have to go under-the-hood by calling buffer

@illicitonion
Copy link
Contributor

illicitonion left a comment

Thanks!

@illicitonion illicitonion merged commit fa6185a into pantsbuild:master Jul 25, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:py3-fixes_process-handler branch Jul 25, 2018

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment