generated from deepgram/oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
What is the current behavior?
When calling finish() on AsyncListenWebSocketClient, if an error occurs, the implementation swallows asyncio.CancelledError. This can lead to async tasks not being properly cancelled, leaving background tasks or threads hanging.
Steps to reproduce
- Run Deepgram inside an asyncio task.
- From outside, cancel that task while it is in the middle of await finish().
- Because of the race condition between the cancellation signal and the shutdown sequence,
finish()swallows theCancelledError.
Expected behavior
finish() should properly propagate CancelledError or re-raise after logging.
Please tell us about your environment
This issue is happening inside Pipecat, when we are cancelling the Pipeline.
For now we have included a workaround to prevent the Pipeline from freezing due to this.
Other information
Since CancelledError is a control-flow exception in asyncio and should normally propagate, catching it without re-raising breaks task cancellation semantics. This can result in:
- Potential resource leaks or threads that remain active after shutdown
- Inconsistent cleanup behavior if cancellation occurs during finish()
Metadata
Metadata
Assignees
Labels
No labels