The problem arises when async functions like hapi.createNode may start a cooking thread that may try to run Python code. That is, we would now have Python running on two different threads - something not allowed by Python by default.
We need to tell Python to explicitly “pause” the Python state on the client thread while we run Python in our cooking thread.
You must call this function first with locked == True before any async HAPI call. Then, after the async call finished, detected via calls to hapi.getStatus call this method again to release the lock with locked == False.
Usage ¶
pythonThreadInterpreterLock(session
: hapi.Session, locked
: bool
) → bool
Acquires or releases the Python interpreter lock. This is needed if HAPI is called from Python and HAPI is in threaded mode (see hapi.initialize.
session
The session of Houdini you are interacting with. See hapi.Session for more on sessions. Pass None to just use the default in-process session.
locked
True will acquire the interpreter lock to use it for the HAPI cooking thread. False will release the lock back to the client thread.