-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a initiate chats #1938
Fix a initiate chats #1938
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1938 +/- ##
===========================================
+ Coverage 36.90% 56.09% +19.18%
===========================================
Files 66 66
Lines 7031 7058 +27
Branches 1538 1668 +130
===========================================
+ Hits 2595 3959 +1364
+ Misses 4210 2768 -1442
- Partials 226 331 +105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
* Fix async a_initiate_chats * Fix type compatibility for python 3.8 * Use partial func to fix context error * website/docs/tutorial/assets/conversable-agent.jpg: convert to Git LFS * Update notebook examples --------- Co-authored-by: Chi Wang <wang.chi@microsoft.com> Co-authored-by: Davor Runje <davor@airt.ai>
Why are these changes needed?
TLDR. The bug is at https://github.com/microsoft/autogen/blob/main/autogen/agentchat/chat.py#L214
When I used await inside an '''async with condition block'' that's controlling access to a shared resource with an asyncio.Condition, the coroutine will pause at the await and yield control back to the event loop. This does not block the entire program; rather, it allows other coroutines to run while this one is waiting.
However, the async with block will hold onto the condition's lock until the block is exited, which means other coroutines that want to acquire the condition (for example, to notify waiting coroutines that something has happened) will have to wait until the lock is released.
To fix the bug, the new approach is to use asyncio.Task to create a Task per chat. Chat Tasks will be executed once it is created. In detail,
await sender.a_initiate_chat(**chat_info) is wrapped inside Task.
None dependent chats could execute concurrently.
"await" the prerequisite chat results before create the new chat when necessary.
Related issue number
Checks