Commit 2d460b6
committed
fix: prevent race condition in listener iteration
Fixed RuntimeError when listeners list is modified during event emission.
The _emit_event() method now copies the listeners list before iteration
to prevent modification during async iteration.
Scenario:
1. _emit_event() iterates listeners and awaits on_event()
2. During await, cleanup or other code calls remove_listener()
3. List modified during iteration causes RuntimeError
Fix: Create a shallow copy of listeners list before iterating,
allowing safe concurrent modifications without affecting ongoing iteration.
Test results: All 23 tests in tests/realtime/test_openai_realtime.py passed1 parent d1abf43 commit 2d460b6
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
| 269 | + | |
| 270 | + | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
| |||
0 commit comments