def METHOD_NAME(self, fd):
    transport = self._transport.get_pipe_transport(fd)
    if fd == 2:
        stream = self.stderr
    else:
        assert fd == 1
        stream = self.stdout
    if self._loop.get_debug():
        name = 'stdout' if fd == 1 else 'stderr'
        logger.debug('%r communicate: read %s', self, name)
    output = yield from stream.read()
    if self._loop.get_debug():
        name = 'stdout' if fd == 1 else 'stderr'
        logger.debug('%r communicate: close %s', self, name)
    transport.close()
    return output