mirror of https://github.com/grpc/grpc.git
[Cython AIO] Fix Aio tests time out issue (#37917)
### What's happening Some of our asyncio tests began timing out following a Cython upgrade to 3.0. This issue occurs consistently across both our Bazel and setup.py test environments. ### Why the time out After some investigation, we found that our code here:pull/37896/head4ffcdd4ab7/src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi (L115-L116)
Was translated to this in Cython 0.29: ``` __pyx_f_7_cython_6cygrpc__unified_socket_write(__pyx_v_self->_write_fd); ``` And it changed to this in Cython 3.0: ``` __pyx_f_7_cython_6cygrpc__unified_socket_write(__pyx_v_self->_write_fd); if (unlikely(__Pyx_ErrOccurredWithGIL())) __PYX_ERR(7, 136, __pyx_L1_error) ``` Which indicates that this `nogil` function `_unified_socket_write` now requires GIL. ### What's new in Cython 3 * Cython 3 `cdef` functions with `void` return type will default to use `except *` as exception specification. * If function have `void` return type and defined as `nogil`, Cython will always re-acquire the GIL after the function call to check if an exception has been raised. * In some cases, this will cause a deadlock, especially if the function was called inside another `nogil` function. ### What's the fix * This PR changes those functions to use `noexcept` as exception specification since we don't expect them to throw any exception, and this is also the suggested workarounds in Cython documentation: https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#error-return-values ### Test * Tested locally by running `bazel test`, time our rate decreased from 5% to 0.3% in 3000 runs and 10s test time out. <!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. --> Closes #37917 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37917 from XuanWang-Amos:fix_cython_aio063d27aee9
PiperOrigin-RevId: 685851320
parent
47faab618b
commit
7ea88447d9
2 changed files with 5 additions and 5 deletions
Loading…
Reference in new issue