TaskObserver: don't inspect on_push_frame signature for every frame
This commit is contained in:
@@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Fixed an issue with the `TavusVideoService` where an error was thrown due to
|
- Fixed an issue with the `TavusVideoService` where an error was thrown due to
|
||||||
missing transcription callbacks.
|
missing transcription callbacks.
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
- Fixed an issue in `TaskObserver` (a proxy to all observers) that was degrading
|
||||||
|
global performance.
|
||||||
|
|
||||||
## [0.0.77] - 2025-07-31
|
## [0.0.77] - 2025-07-31
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -153,22 +153,23 @@ class TaskObserver(BaseObserver):
|
|||||||
|
|
||||||
async def _proxy_task_handler(self, queue: asyncio.Queue, observer: BaseObserver):
|
async def _proxy_task_handler(self, queue: asyncio.Queue, observer: BaseObserver):
|
||||||
"""Handle frame processing for a single observer."""
|
"""Handle frame processing for a single observer."""
|
||||||
warning_reported = False
|
on_push_frame_deprecated = False
|
||||||
|
signature = inspect.signature(observer.on_push_frame)
|
||||||
|
if len(signature.parameters) > 1:
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter("always")
|
||||||
|
warnings.warn(
|
||||||
|
"Observer `on_push_frame(source, destination, frame, direction, timestamp)` is deprecated, us `on_push_frame(data: FramePushed)` instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
)
|
||||||
|
|
||||||
|
on_push_frame_deprecated = True
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = await queue.get()
|
data = await queue.get()
|
||||||
|
if on_push_frame_deprecated:
|
||||||
signature = inspect.signature(observer.on_push_frame)
|
|
||||||
if len(signature.parameters) > 1:
|
|
||||||
if not warning_reported:
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.simplefilter("always")
|
|
||||||
warnings.warn(
|
|
||||||
"Observer `on_push_frame(source, destination, frame, direction, timestamp)` is deprecated, us `on_push_frame(data: FramePushed)` instead.",
|
|
||||||
DeprecationWarning,
|
|
||||||
)
|
|
||||||
warning_reported = True
|
|
||||||
await observer.on_push_frame(
|
await observer.on_push_frame(
|
||||||
data.src, data.dst, data.frame, data.direction, data.timestamp
|
data.src, data.dst, data.frame, data.direction, data.timestamp
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user