Skip to content

fix(helpers): use running loop in voice helpers - #3807

Open
Ghraven wants to merge 1 commit into
openai:mainfrom
Ghraven:raven-voice-helpers-running-loop
Open

fix(helpers): use running loop in voice helpers#3807
Ghraven wants to merge 1 commit into
openai:mainfrom
Ghraven:raven-voice-helpers-running-loop

Conversation

@Ghraven

@Ghraven Ghraven commented Sep 6, 2026

Copy link
Copy Markdown

Problem

The voice helper async methods are already running inside coroutines, but they call asyncio.get_event_loop() before using the loop for thread-safe callbacks and executor work. On modern Python, asyncio.get_running_loop() is the clearer API in this context and avoids depending on event-loop policy fallback behavior.

Before / after

Before, Microphone.record(), LocalAudioPlayer.play(), and LocalAudioPlayer.play_stream() fetched the event loop with get_event_loop().

After, those async methods capture the currently running loop with get_running_loop() while keeping the existing call_soon_threadsafe() and run_in_executor() behavior unchanged.

Verification

  • python -m py_compile src/openai/helpers/microphone.py src/openai/helpers/local_audio_player.py
  • git diff --check

I did not run a hardware audio smoke test locally.

@Ghraven
Ghraven requested a review from a team as a code owner September 6, 2026 08:46
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