Cirq
Cirq copied to clipboard
Ignore spurious PollerCompletionQueue errors in AsyncioExecutor
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 BlockingIOError
s from the PollerCompletionQueue
so that we don't spam the logs with scary-looking messages when using grpc with asyncio from multiple threads.
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.