BaseObject: don't create event handler tasks if none is registered
This commit is contained in:
@@ -81,7 +81,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### 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
|
### Other
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ class BaseObject(ABC):
|
|||||||
self._event_handlers[event_name] = []
|
self._event_handlers[event_name] = []
|
||||||
|
|
||||||
async def _call_event_handler(self, event_name: str, *args, **kwargs):
|
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.
|
# Create the task.
|
||||||
task = asyncio.create_task(self._run_task(event_name, *args, **kwargs))
|
task = asyncio.create_task(self._run_task(event_name, *args, **kwargs))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user