Skip to content

Commit a3b4992

Browse files
committed
made update_period optional in Updater
A
1 parent c867e79 commit a3b4992

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/fastcs/attributes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ async def put(self, controller: Any, attr: AttrW, value: Any) -> None:
2626
class Updater(Protocol):
2727
"""Protocol for updating the cached readback value of an ``Attribute``."""
2828

29-
update_period: float
29+
# If update period is None then the attribute will not be updated as a task.
30+
update_period: float | None
3031

3132
async def update(self, controller: Any, attr: AttrR) -> None:
3233
pass
@@ -52,7 +53,7 @@ def __init__(
5253
group: str | None = None,
5354
handler: Any = None,
5455
allowed_values: list[T] | None = None,
55-
description: str | None = None
56+
description: str | None = None,
5657
) -> None:
5758
assert (
5859
datatype.dtype in ATTRIBUTE_TYPES
@@ -103,7 +104,7 @@ def __init__(
103104
group,
104105
handler,
105106
allowed_values=allowed_values, # type: ignore
106-
description=description
107+
description=description,
107108
)
108109
self._value: T = datatype.dtype()
109110
self._update_callback: AttrCallback[T] | None = None
@@ -136,15 +137,15 @@ def __init__(
136137
group: str | None = None,
137138
handler: Sender | None = None,
138139
allowed_values: list[T] | None = None,
139-
description: str | None = None
140+
description: str | None = None,
140141
) -> None:
141142
super().__init__(
142143
datatype, # type: ignore
143144
access_mode,
144145
group,
145146
handler,
146147
allowed_values=allowed_values, # type: ignore
147-
description=description
148+
description=description,
148149
)
149150
self._process_callback: AttrCallback[T] | None = None
150151
self._write_display_callback: AttrCallback[T] | None = None
@@ -186,15 +187,15 @@ def __init__(
186187
group: str | None = None,
187188
handler: Handler | None = None,
188189
allowed_values: list[T] | None = None,
189-
description: str | None = None
190+
description: str | None = None,
190191
) -> None:
191192
super().__init__(
192193
datatype, # type: ignore
193194
access_mode,
194195
group,
195196
handler,
196197
allowed_values, # type: ignore
197-
description=description
198+
description=description,
198199
)
199200

200201
async def process(self, value: T) -> None:

src/fastcs/backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def _add_attribute_updater_tasks(
137137
callback = _create_updater_callback(
138138
attribute, single_mapping.controller
139139
)
140-
scan_dict[update_period].append(callback)
140+
if update_period is not None:
141+
scan_dict[update_period].append(callback)
141142

142143

143144
def _create_updater_callback(attribute, controller):

0 commit comments

Comments
 (0)