Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Ignore spurious PollerCompletionQueue errors in AsyncioExecutor

Open maffoo opened this issue 11 months ago • 1 comments

When using grpc with asyncio from multiple threads, spurious PollerCompletionQueue errors are printed due to multiple event loops listening a socket to be notified of grpc events. More than one event loop may be woken when the completion queue writes a byte to the notification socket, but only one of the loops receives the data and the others raise a BlockingIOError. This doesn't actually cause a problem in the grpc still works with asyncio in multiple threads, but lots of spurious error messages are printed by the default exception handler. (See https://github.com/grpc/grpc/issues/25364 for discussion of the issue.)

This configures the asyncio event loop used for grpc with an exception handler that ignores these BlockingIOErrors from the PollerCompletionQueue so that we don't spam the logs with scary-looking messages when using grpc with asyncio from multiple threads.

maffoo avatar Mar 12 '24 05:03 maffoo

Note: I filed https://github.com/grpc/grpc/pull/36096 to fix these errors upstream. We'll see what comes of that, but in any case it will be a while before we can rely on that and so I think silencing these errors in our own event loops makes sense.

maffoo avatar Mar 12 '24 17:03 maffoo