Commit e572ce9
Shizoqua
Fix #7100: Add cancellation check in run_stream() to stop iteration immediately
- Add cancellation token check before yielding messages in run_stream()
- Prevents processing buffered messages after cancellation token is cancelled
- Fixes issue where signal handlers (SIGINT/Ctrl+C) couldn't stop iteration immediately
- Add test_round_robin_group_chat_run_stream_cancellation to verify fix
The issue was that run_stream() would continue processing all buffered
messages from the queue even after the cancellation token was cancelled,
because the cancellation check only happened when awaiting the next message.
This fix adds a check after receiving each message to break immediately
if cancellation occurred.1 parent 13e144e commit e572ce9
File tree
2 files changed
+65
-0
lines changed- python/packages/autogen-agentchat
- src/autogen_agentchat/teams/_group_chat
- tests
2 files changed
+65
-0
lines changedLines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
550 | 555 | | |
551 | 556 | | |
552 | 557 | | |
| |||
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
763 | 763 | | |
764 | 764 | | |
765 | 765 | | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
766 | 826 | | |
767 | 827 | | |
768 | 828 | | |
| |||
0 commit comments