gradio
37e4c00b - Fix #13044: cancel generator close in ChatInterface (#13047)

Commit
36 days ago
Fix #13044: cancel generator close in ChatInterface (#13047) * Fix #13044: cancel generator close in ChatInterface Fixed generator cancellation in ChatInterface so that pressing the stop button during streaming now properly calls close() on sync generators, raising GeneratorExit and allowing apps to clean up resources. Added safe_aclose_iterator() in utils.py, which retries closing a SyncToAsyncIterator when the generator is mid-execution, avoiding the ValueError: already executing race condition. Both the main streaming path and the examples streaming path in chat_interface.py now use finally blocks to guarantee the generator is closed regardless of whether cancellation or a normal exit occurs. Fixes #13044 * Use async with aclosing * add changeset --------- Co-authored-by: Freddy Boulton <41651716+freddyaboulton@users.noreply.github.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Author
Parents
Loading