Skip to content

VTK_UNBLOCKTHREADS hint to release Python GIL

David Gobbi requested to merge dgobbi/vtk:python-thread-hint into master

This hint will add PyEval_SaveThread/PyEval_RestoreThread before and after the hinted method call, which allows Python's threads to run concurrently during the method call. Since the Save/Restore adds a small overhead to the method, it only makes sense to add this hint to methods that take a long time (milliseconds) to execute. The most useful places for this hint are I/O methods and Update() methods.

As a prerequisite for this hint to take effect, VTK_PYTHON_FULL_THREADSAFE must be ON when VTK is configured.

For reference, see https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code

Edited by David Gobbi

Merge request reports