Skip to content

fix: use running loop in audio helpers#3495

Open
Ghraven wants to merge 1 commit into
openai:mainfrom
GhravenLabs:fix/audio-helpers-running-loop-20260712
Open

fix: use running loop in audio helpers#3495
Ghraven wants to merge 1 commit into
openai:mainfrom
GhravenLabs:fix/audio-helpers-running-loop-20260712

Conversation

@Ghraven

@Ghraven Ghraven commented Jul 11, 2026

Copy link
Copy Markdown

Summary

  • replace asyncio.get_event_loop() with asyncio.get_running_loop() inside async audio helper methods
  • keep the existing callback behavior by retaining the captured running loop for thread-safe callback notifications and executor calls

Problem

asyncio.get_event_loop() is legacy behavior in modern async code and can behave differently depending on thread/policy state. These methods are already executing inside a running coroutine, so the running loop is the precise loop the helper should capture.

Before / after

Before, Microphone.record(), LocalAudioPlayer.play(), and LocalAudioPlayer.play_stream() asked asyncio for the ambient event loop.

After, they capture the currently running loop directly with asyncio.get_running_loop().

Verification

  • python -m py_compile src\openai\helpers\microphone.py src\openai\helpers\local_audio_player.py
  • git diff --check
  • confirmed no remaining get_event_loop() calls in the touched helper files

@Ghraven Ghraven requested a review from a team as a code owner July 11, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant