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:
object
Manager 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.Event
that is set when config changes are written
- readonly_override: tallypi.manager.ReadonlyOverride¶
A context manager that can temporarily disable
readonly
modeFor details, see the
ReadonlyOverride
class
- property readonly: bool¶
If
True
config 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 theinputs
andoutputs
- 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:
object
An asynchronous context manager used to override the
readonly
mode ofManager
While the context is acquired, the
Manager
is temporarily allowed to write config changes. Theconfig_write_evt
event is returned so it will be available as the as clause of theasync with
statement:async with manager.readonly_override as config_write_evt: await manager.remove_input('foo') await config_write_evt.wait()
This allows code to
await
for config changes to be written before exiting theasync with
context.- 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]¶
True
if the context is acquired or ifstate_lock
is locked
- async acquire()[source]¶
Acquire the context and set
override
toTrue
Also clears
config_write_evt
so it can be awaited
Container Classes¶
- class tallypi.manager.IOContainer(*args, **kwargs)[source]¶
Bases:
pydispatch.dispatch.Dispatcher
Container for
BaseIO
instances- 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.IOContainer
Container for
BaseInput
instances- Events
- on_tally_added(inp: BaseInput, tally: tslumd.tallyobj.Tally)¶
Fired when the
baseio.BaseInput.on_tally_added
event 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_updated
event 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.IOContainer
Container for
BaseOutput
instances- async bind_all_to_input(inp: tallypi.baseio.BaseInput)[source]¶
Attach all
outputs
to the giveninput
Calls
baseio.BaseOutput.bind_to_input()
for each output instance
- async unbind_all_from_input(inp: tallypi.baseio.BaseInput)[source]¶
Unbind all
outpus
from the giveninput
Calls
baseio.BaseOutput.unbind_from_input()
for each output instance