Skip to content

Commit

Permalink
[fix] Don't replace buffer, but make sure stream has buffer attr.
Browse files Browse the repository at this point in the history
  • Loading branch information
OniOni committed Jan 24, 2019
1 parent 87a3fdb commit f94550e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/python/pants/pantsd/pants_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def isatty(self):
def fileno(self):
return self._handler.stream.fileno()

@property
def buffer(self):
return self


class PantsDaemon(FingerprintedProcessManager):
"""A daemon that manages PantsService instances."""
Expand Down Expand Up @@ -298,14 +302,8 @@ def _pantsd_logging(self):
# Do a python-level redirect of stdout/stderr, which will not disturb `0,1,2`.
# TODO: Consider giving these pipes/actual fds, in order to make them "deep" replacements
# for `1,2`, and allow them to be used via `stdio_as`.
new_stdout = _LoggerStream(logging.getLogger(), logging.INFO, result.log_handler)
new_stderr = _LoggerStream(logging.getLogger(), logging.WARN, result.log_handler)
if PY3:
sys.stdout.buffer = new_stdout
sys.stderr.buffer = new_stderr
else:
sys.stdout = new_stdout
sys.stderr = new_stderr
sys.stdout = _LoggerStream(logging.getLogger(), logging.INFO, result.log_handler)
sys.stderr = _LoggerStream(logging.getLogger(), logging.WARN, result.log_handler)

self._logger.debug('logging initialized')
yield result.log_handler.stream
Expand Down

0 comments on commit f94550e

Please sign in to comment.