manager Module¶
Manager Class¶
- class tallypi.manager.Manager(config_filename: Optional[pathlib.Path] = PosixPath('/home/docs/.config/tallypi.yaml'), readonly: Optional[bool] = False)[source]¶
Bases:
objectManager for tally inputs and outputs
- inputs: tallypi.manager.Inputs¶
All configured inputs
- outputs: tallypi.manager.Outputs¶
All configured outputs
- config: tallypi.config.Config¶
Configuration storage
- config_write_evt: asyncio.locks.Event¶
An
asyncio.events.Eventthat is set when config changes are written
- readonly_override: tallypi.manager.ReadonlyOverride¶
A context manager that can temporarily disable
readonlymodeFor details, see the
ReadonlyOverrideclass
- property readonly: bool¶
If
Trueconfig changes are not written to disk (unless overridden)This is the immutable “readonly” state
- async open()[source]¶
Opens all inputs and outputs
Reads configuration data if necessary with a call to
read_config(), then callsopen()on theinputsandoutputs
- async add_input(obj: tallypi.baseio.BaseInput)[source]¶
Add an input
Shortcut for calling
IOContainer.add()oninputs
- async add_output(obj: tallypi.baseio.BaseOutput)[source]¶
Add an input
Shortcut for calling
IOContainer.add()onoutputs
- class tallypi.manager.ReadonlyOverride(config_write_evt: asyncio.locks.Event)[source]¶
Bases:
objectAn asynchronous context manager used to override the
readonlymode ofManagerWhile the context is acquired, the
Manageris temporarily allowed to write config changes. Theconfig_write_evtevent is returned so it will be available as the as clause of theasync withstatement:async with manager.readonly_override as config_write_evt: await manager.remove_input('foo') await config_write_evt.wait()
This allows code to
awaitfor config changes to be written before exiting theasync withcontext.- config_write_evt: asyncio.locks.Event¶
Alias for
Manager.config_write_evt
- state_lock: asyncio.locks.Lock¶
A lock used while changing states
- locked()[source]¶
Trueif the context is acquired or ifstate_lockis locked
- async acquire()[source]¶
Acquire the context and set
overridetoTrueAlso clears
config_write_evtso it can be awaited
Container Classes¶
- class tallypi.manager.IOContainer(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.DispatcherContainer for
BaseIOinstances- Events
- object_added(key: str, obj: tallypi.baseio.BaseIO)¶
Fired when an instance is added by either
deserialize()oradd()
- object_removed(key: str, obj: tallypi.baseio.BaseIO)¶
Fired when an instance has been removed
- update()¶
Fired when any change happens that requires a config update
- async add(obj: tallypi.baseio.BaseIO, key: Optional[str] = None)[source]¶
Add an instance to the container
- Parameters
obj (BaseIO) – The instance to add
key (str, optional) – The key for the instance. If not given, one will be created by
key_for_object()
- async replace(key: str, obj: tallypi.baseio.BaseIO)[source]¶
Replace an instance by the given key
- key_for_object(obj: tallypi.baseio.BaseIO)[source]¶
Create a unique key based on the class namespace
- async deserialize(data: Dict)[source]¶
Deserialize instances from config data using
baseio.BaseIO.deserialize()
- serialize() → Dict[source]¶
Serialize instances to store in the config using
baseio.BaseIO.serialize()
- class tallypi.manager.Inputs(*args, **kwargs)[source]¶
Bases:
tallypi.manager.IOContainerContainer for
BaseInputinstances- Events
- on_tally_added(inp: BaseInput, tally: tslumd.tallyobj.Tally)¶
Fired when the
baseio.BaseInput.on_tally_addedevent received from any of the inputs in the container
- on_tally_updated(inp: BaseInput, tally: tslumd.tallyobj.Tally)¶
Fired when the
baseio.BaseInput.on_tally_updatedevent received from any of the inputs in the container
- async add(obj: tallypi.baseio.BaseInput, key: Optional[str] = None)[source]¶
Add an instance to the container
- async deserialize(data: Dict)[source]¶
Deserialize instances from config data using
baseio.BaseIO.deserialize()
- class tallypi.manager.Outputs(*args, **kwargs)[source]¶
Bases:
tallypi.manager.IOContainerContainer for
BaseOutputinstances- async bind_all_to_input(inp: tallypi.baseio.BaseInput)[source]¶
Attach all
outputsto the giveninputCalls
baseio.BaseOutput.bind_to_input()for each output instance
- async unbind_all_from_input(inp: tallypi.baseio.BaseInput)[source]¶
Unbind all
outpusfrom the giveninputCalls
baseio.BaseOutput.unbind_from_input()for each output instance