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
[Python] Handle BlockingIOError if multiple loops are bound to PollerCompletionQueue #36096
base: master
Are you sure you want to change the base?
Conversation
Thanks for the contribution! I don't believe we currently have any tests that cover operating with multiple event loops. Do you think you could help by contribution one that replicates your setup? |
@gnossen, I added a basic test of using python tools/run_tests/run_tests.py -l python --compiler python3.12 in a python 3.12 virtualenv, but that fails with an error while building wheels. Any additional pointers you have about running tests locally would be greatly appreciated. |
Hi, thanks for contributing the test! Do you mind share more information about the failures? In the meanwhile, you can also trigger the test using
|
Looks like the new test is timing out, do you mind take a look? |
Looks like the distribtest failure is an unrelated non-hermetic regression on the master branch unrelated to this PR. (cause). We'll take care of that out of band. |
Fixes #25364
When using grpc with multiple asyncio event loops in different threads, we may have multiple loops bound to the same
PollerCompletionQueue
. If the event loops support file descriptor monitoring, each loop will be configured withloop.add_reader
to handle read events on the notification socket. This means that when completion events are available,PollerCompletionQueue._handle_events
may be called multiple times for the different loops, but only one call will actually receive the byte written to the notification socket. The other calls will raiseBlockingIOError
, which then bubbles up and gets printed by the event loop's default exception handler, resulting in spurious error messages since things are in fact working fine. This changes_handle_events
to catch and supress theseBlockingIOError
s.