Repair `Broken pipe` on pantsd thin client execution when piped to a non-draining reader. #4230

Merged
merged 4 commits into from Feb 3, 2017

Conversation

Projects
None yet
2 participants
@kwlzn
Member

kwlzn commented Feb 2, 2017

Problem

When piping output of the pantsd thin client to e.g. head, the client will throw an unhandled Broken pipe IOError attempting to flush the now-defunct fd after head short-circuits after consuming only its needed output.

Solution

Catch Broken pipe errors and exit when encountered.

Result

Broken pipe is no longer seen.

Fixes #4166

@kwlzn kwlzn changed the title from Repair `Broken pipe` on pantsd thin client when piped to a non-draining reader. to Repair `Broken pipe` on pantsd thin client execution when piped to a non-draining reader. Feb 2, 2017

@kwlzn kwlzn requested review from stuhood, jsirois and peiyuwang Feb 2, 2017

@stuhood

stuhood approved these changes Feb 2, 2017

Thanks Kris!

src/python/pants/java/nailgun_client.py
@@ -57,6 +58,12 @@ def _process_session(self):
self._maybe_start_input_reader()
else:
raise self.ProtocolError('received unexpected chunk {} -> {}'.format(chunk_type, payload))
+ except (IOError, OSError) as e:
+ # If a `Broken Pipe` is encountered during a stdio fd write, we're headless - bail.

This comment has been minimized.

@stuhood

stuhood Feb 2, 2017

Member

I'm guessing that you should only get EPIPE when dealing with _stdout/_stderr here, and never when dealing with the socket?

@stuhood

stuhood Feb 2, 2017

Member

I'm guessing that you should only get EPIPE when dealing with _stdout/_stderr here, and never when dealing with the socket?

This comment has been minimized.

@kwlzn

kwlzn Feb 3, 2017

Member

tightened this up a bit.

@kwlzn

kwlzn Feb 3, 2017

Member

tightened this up a bit.

@kwlzn kwlzn merged commit e83f059 into pantsbuild:master Feb 3, 2017

1 check passed

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

lenucksi added a commit to lenucksi/pants that referenced this pull request Apr 25, 2017

Repair `Broken pipe` on pantsd thin client execution when piped to a …
…non-draining reader. (#4230)

Problem

When piping output of the pantsd thin client to e.g. head, the client will throw an unhandled Broken pipe IOError attempting to flush the now-defunct fd after head short-circuits after consuming only its needed output.

Solution

Catch Broken pipe errors and exit when encountered.

Result

Broken pipe is no longer seen.

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