runtimepy.mixins package#
Submodules#
runtimepy.mixins.async_command module#
A module implementing an interface for classes with channel-command processors that need to handle commands asynchronously.
- class runtimepy.mixins.async_command.AsyncCommandProcessingMixin(logger: Logger | LoggerAdapter[Any] = None, logger_name: str = None)[source]#
Bases:
LoggerMixin
A class mixin for handling asynchronous commands.
- command: ChannelCommandProcessor#
- async handle_command(args: Namespace, channel: BitField | Channel[Int8Primitive] | Channel[Int16Primitive] | Channel[Int32Primitive] | Channel[Int64Primitive] | Channel[Uint8Primitive] | Channel[Uint16Primitive] | Channel[Uint32Primitive] | Channel[Uint64Primitive] | Channel[FloatPrimitive] | Channel[DoublePrimitive] | Channel[BooleanPrimitive] | None) None [source]#
Handle a command.
- outgoing_commands: Queue[tuple[Namespace, BitField | Channel[Int8Primitive] | Channel[Int16Primitive] | Channel[Int32Primitive] | Channel[Int64Primitive] | Channel[Uint8Primitive] | Channel[Uint16Primitive] | Channel[Uint32Primitive] | Channel[Uint64Primitive] | Channel[FloatPrimitive] | Channel[DoublePrimitive] | Channel[BooleanPrimitive] | None]]#
runtimepy.mixins.enum module#
A module implementing a class mixin for classes that have an optional enum-registry key.
runtimepy.mixins.environment module#
A module implementing a channel-environment class mixin.
- class runtimepy.mixins.environment.ChannelEnvironmentMixin(env: ChannelEnvironment = None, **kwargs)[source]#
Bases:
object
A simple channel-environment mixin.
- env: ChannelEnvironment#
- register_channel_metrics(name: str, channel: ChannelMetrics, verb: str) None [source]#
Register individual channel metrics.
- register_connection_metrics(metrics: ConnectionMetrics, *names: str, namespace: str = 'metrics') None [source]#
Register connection metrics.
- register_task_metrics(metrics: PeriodicTaskMetrics, *names: str, namespace: str = 'metrics') None [source]#
Register periodic task metrics.
runtimepy.mixins.finalize module#
A module implementing a class with a simple finalize interface.
- class runtimepy.mixins.finalize.FinalizeMixin(event: Event = None)[source]#
Bases:
object
A class implementing a simple finalize interface.
- bypass_finalized() Iterator[None] [source]#
Allows bypassing ‘finalized’ checks for specific situations. Ideally runtime environment entities don’t rely on this, but things like self-describing network protocols it’s difficult to resolve runtime-state storage needs during initialization alone.
- property finalized: bool#
Determine if this instance is finalized or not.
runtimepy.mixins.logging module#
A module implementing a logger-mixin extension.
- class runtimepy.mixins.logging.LogCaptureMixin[source]#
Bases:
object
A simple async file-reading interface.
- async init_log_capture(stack: AsyncExitStack, log_paths: Iterable[tuple[LogLevel | int | str, Path | str | None]]) None [source]#
Initialize this task with application information.
- logger: Logger | LoggerAdapter[Any]#
- safe_to_log = True#
- streams: list[tuple[int, Any]]#
- class runtimepy.mixins.logging.LogLevel(*values)[source]#
Bases:
RuntimeIntEnum
A runtime enumeration for log level.
- CRITICAL = 50#
- DEBUG = 10#
- ERROR = 40#
- INFO = 20#
- WARNING = 30#
- class runtimepy.mixins.logging.LoggerMixinLevelControl(logger: Logger | LoggerAdapter[Any] = None, logger_name: str = None)[source]#
Bases:
LoggerMixin
A logger mixin that exposes a runtime-controllable level.
- setup_level_channel(env: ChannelEnvironment, name: str = 'log_level', initial: str = 'info', description: str = 'Text-log level filter for this environment.') None [source]#
Add a commandable log-level channel to the environment.
runtimepy.mixins.psutil module#
A module implementing interfaces for psutil.
- class runtimepy.mixins.psutil.PsutilMixin[source]#
Bases:
object
A simple psutil runtime interface.
- cpu_average: WeightedAverage#
- cpu_percent: FloatPrimitive#
- init_psutil(env: ChannelEnvironment) None [source]#
Initialize psutil-based metrics.
- memory_percent: FloatPrimitive#
- process: Process#
runtimepy.mixins.regex module#
A class mixin for classes that have a regular expression that they wish to validate names with.
runtimepy.mixins.trig module#
A module implementing a simple trig-channel environment mixin.
- class runtimepy.mixins.trig.TrigMixin(env: ChannelEnvironment, steps_controls: dict[str, int | float | bool | dict[str, int | float | bool]] | str = 'steps', amplitude_controls: dict[str, int | float | bool | dict[str, int | float | bool]] | str = 'amplitude', phase_angle_controls: dict[str, int | float | bool | dict[str, int | float | bool]] | str = 'phase')[source]#
Bases:
object
A simple trig mixin class.