Unlike ctypes, Cython by default do not release GIL when
calling into C API functions. This causes problems when the
function is long running. As the particular calling thread will
block other python threads by holding the GIL.

This PR explicitly releases GIL when calling into possible
long running functions. It fixes the timeout issue in
PopenPool which previously relied on another python thread
for timeout.

This PR is covered by a regression test-case by changing time.sleep to sleep
in FFI, which previously will indefinitely block the popen tests.

You can view, comment on, or merge this pull request online at:

  https://github.com/apache/tvm/pull/11461

-- Commit Summary --

  * [FFI][CYTHON] Release GIL when calling into long running functions

-- File Changes --

    M python/tvm/_ffi/_cython/base.pxi (36)
    M python/tvm/_ffi/_cython/ndarray.pxi (20)
    M python/tvm/_ffi/_cython/object.pxi (4)
    M python/tvm/_ffi/_cython/packed_func.pxi (32)
    M python/tvm/testing/popen_pool.py (3)
    M python/tvm/testing/utils.py (6)
    M src/support/ffi_testing.cc (6)

-- Patch Links --

https://github.com/apache/tvm/pull/11461.patch
https://github.com/apache/tvm/pull/11461.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/apache/tvm/pull/11461
You are receiving this because you are subscribed to this thread.

Message ID: <apache/tvm/pull/11...@github.com>

Reply via email to