From e804060e170c8979512475e7deacca113f59da81 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Mon, 23 Feb 2026 15:45:00 -0500 Subject: [PATCH] Update COMMUNITY_INTEGRATIONS.md _update_settings examples Simplify the reconnect example to show a common pattern (reconnect on any change) and improve the _warn_unhandled_updated_settings example to show selective handling of specific fields. --- COMMUNITY_INTEGRATIONS.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/COMMUNITY_INTEGRATIONS.md b/COMMUNITY_INTEGRATIONS.md index 32fbff333..642754451 100644 --- a/COMMUNITY_INTEGRATIONS.md +++ b/COMMUNITY_INTEGRATIONS.md @@ -266,17 +266,18 @@ class MySTTService(STTService): self._sync_model_name_to_metrics() ``` -To react to runtime setting changes, override `_update_settings`. The base implementation applies the delta to `self._settings` and returns a `dict` mapping each changed field name to its **pre-update** value. Your override should call `super()` first, then act on the changed fields: +To react to runtime setting changes, override `_update_settings`. The base implementation applies the delta to `self._settings` and returns a `dict` mapping each changed field name to its **pre-update** value. Your override should call `super()` first, then act on the changed fields. A common implementation might look like: ```python async def _update_settings(self, update: STTSettings) -> dict[str, Any]: """Apply a settings update, reconfiguring the recognizer if needed.""" changed = await super()._update_settings(update) - if "language" in changed: - # Restart the recognizer with the new language. - await self._disconnect() - await self._connect() + if not changed: + return changed + + await self._disconnect() + await self._connect() return changed ``` @@ -285,7 +286,7 @@ The dict keys work like a set for membership tests (`"language" in changed`) and Note that, in this example, the service requires a reconnect to apply the new language. Consider, for each setting, whether your service requires reconnection or can apply changes in-place. -If your service can't yet apply certain settings at runtime, call `self._warn_unhandled_updated_settings(changed)` with the unhandled field names so users get a clear log message: +If your service can't yet apply certain settings at runtime, call `self._warn_unhandled_updated_settings(changed)` with any unhandled field names so users get a clear log message: ```python async def _update_settings(self, update: STTSettings) -> dict[str, Any]: @@ -294,8 +295,11 @@ async def _update_settings(self, update: STTSettings) -> dict[str, Any]: if not changed: return changed - # TODO: someday we could reconnect here to apply updated settings. - self._warn_unhandled_updated_settings(changed) + if "language" in changed: + await self._update_language() + else: + # TODO: handle changes to other settings soon! + self._warn_unhandled_updated_settings(changed.keys() - {"language"}) return changed ```