Skip to content

StdoutStream

Base classes

Name Children Inherits
ByteSendStream
anyio.abc
An interface for sending bytes to a single peer.

⋔ Inheritance diagram

graph TD
  95970862969680["stdio.StdoutStream"]
  95970857789632["abc.ByteSendStream"]
  95970858096192["abc.AsyncResource"]
  125067848591872["builtins.object"]
  95970857796432["_typedattr.TypedAttributeProvider"]
  95970857789632 --> 95970862969680
  95970858096192 --> 95970857789632
  125067848591872 --> 95970858096192
  95970857796432 --> 95970857789632
  125067848591872 --> 95970857796432

🛈 DocStrings

Bases: ByteSendStream

Wrapper for stdout that implements ByteSendStream interface.

Source code in src/aclientp/stdio.py
class StdoutStream(ByteSendStream):
    """Wrapper for stdout that implements ByteSendStream interface."""

    async def send(self, item: bytes) -> None:
        """Write bytes to stdout."""
        loop = asyncio.get_running_loop()
        await loop.run_in_executor(None, self._write, item)

    def _write(self, data: bytes) -> None:
        sys.stdout.buffer.write(data)
        sys.stdout.buffer.flush()

    async def aclose(self) -> None:
        """Close is a no-op for stdout."""

aclose async

aclose() -> None

Close is a no-op for stdout.

Source code in src/aclientp/stdio.py
async def aclose(self) -> None:
    """Close is a no-op for stdout."""

send async

send(item: bytes) -> None

Write bytes to stdout.

Source code in src/aclientp/stdio.py
async def send(self, item: bytes) -> None:
    """Write bytes to stdout."""
    loop = asyncio.get_running_loop()
    await loop.run_in_executor(None, self._write, item)

:fa-brands-github: Show source on GitHub