unitelabs.bus.transports.read_transport

Classes

  • ReadTransport

    Interface for read-only transports.

    Bases
    asyncio.ReadTransport,

    Methods

    • __init__(self) -> None

    • open(self) -> None

      Opens the transport and sets state to allow future read operations.

    • close(self) -> None

      Closes the transport and sets state to disallow further read operations.

    • is_reading(self) -> bool

      Whether or not reading operations are currently being performed.

      Response

      Type
      bool
      Description

      True if the transport is receiving, otherwise False.

    • pause_reading(self) -> None

      Pause the receiving end. No data will be passed to the protocol's `data_received()` method until `resume_reading()` is called.

    • resume_reading(self) -> None

      Resume the receiving end. Data received will once again be passed to the protocol's `data_received()` method.

    • _abort(self, exception : typing.Optional[Exception]) -> None

      Closes the transport immediately and updates state to disable further read operations.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        exception
        Type
        typing.Optional[Exception]
        Default
        = None
        Description

        The Exception to propagate to the protocol when aborting, if connected.

    • _ensure_reader(self) -> None

      Set state to enable future read operations.

    • _remove_reader(self) -> None

      Set state to disable further read operations.

    • _safe_read(self) -> None

      Safely and asynchronously read data from the transport.

    • _read(self) -> typing.Optional[bytes]

      Read data from the transport. Called within `_safe_read` for asynchronous reading.

      Response

      Type
      typing.Optional[bytes]
      Description

      Data read from the transport.

    • read_all(self) -> bytes

      Read all available data from the transport. Repeatedly calls `_read` and aggregates the results until no further data is available.

      Response

      Type
      bytes
      Description

      All available data from the transport.

    • clear_read_buffer(self) -> None

      Clears out all available read data without notifying the protocol. Calls `read_all` and throws away the result.

    • get_protocol(self) -> typing.Optional[P_co]

      Get the current `Protocol` associated with this transport.

      Response

      Type
      typing.Optional[P_co]
      Description

      The current `Protocol` instance.

    • set_protocol(self, protocol : P_co) -> None

      Associate a new `Protocol` with this transport.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        protocol
        Type
        P_co
        Default
        Description

        The new `Protocol` instance.

      Exceptions

      Type
      TypeError
      Description
      If the protocol is not an instance of asyncio.BaseProtocol or None.
    • is_closing(self) -> bool

      Whether the transport is closing or closed.

      Response

      Type
      bool
      Description

      True if the transport is closing or closed, False otherwise.

    • _open(self) -> None

      Underlying action performed when calling `open`. Subclasses override this method to specify behavior when opening the connection.

    • _close(self) -> None

      Underlying action performed when calling `close`. Subclasses override this method to specify behavior when closing the connection.

    • abort(self) -> None

      Close the transport immediately.

    • _exception(
        self,
        exception : Exception,
        message : str
      ) -> None

      Report a fatal error to the event-loop and abort the transport.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        exception
        Type
        Exception
        Default
        Description

        The Exception to pass on the the loop's exception handler.

      • Name
        message
        Type
        str
        Default
        Description

        Human-readable text describing the exception's execution state, cause, etc.

    Attributes

    • Name
      _has_reader
      Type
      Value

      = False

      Description

    • Name
      _loop
      Type
      Value

      = asyncio.get_event_loop_policy().get_event_loop()

      Description

    • Name
      _protocol
      Type
      typing.Optional[P_co]
      Value

      = None

      Description

    • Name
      _is_closing
      Type
      Value

      = True

      Description

Copyright © 2024