BaseObject: don't create event handler tasks if none is registered

This commit is contained in:
Aleix Conchillo Flaqué
2025-05-19 09:24:56 -07:00
parent 2b66eddaa1
commit 5e5060a6fe
2 changed files with 13 additions and 1 deletions

View File

@@ -81,7 +81,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed an issue with `CartesiaTTSService` where `TTSTextFrame` messages weren't being emitted when the model was set to `sonic`. This resulted in the assistant context not being updated with assistant messages.
- Fixed an issue with `CartesiaTTSService` where `TTSTextFrame` messages weren't
being emitted when the model was set to `sonic`. This resulted in the
assistant context not being updated with assistant messages.
### Performance
- Don't create event handler tasks if no user event handlers have been
registered.
### Other

View File

@@ -59,6 +59,11 @@ class BaseObject(ABC):
self._event_handlers[event_name] = []
async def _call_event_handler(self, event_name: str, *args, **kwargs):
# If we haven't registered an event handler, we don't need to do
# anything.
if not self._event_handlers.get(event_name):
return
# Create the task.
task = asyncio.create_task(self._run_task(event_name, *args, **kwargs))