You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From documentation on gil locking, I couldn't get an understanding of how to use gil_scoped_release and gil_scoped_acquire correctly.
From this test I could understand that you have to gil_scoped_release once before running multiple threads and then gil_scoped_acquire in each thread and it works correctly in my application.
is there a guideline of how to use these two locks if I want to write c++ function f that executes some python code and make f be thread safe?
I already have one instance of scoped_interpreter that is created once for the whole application. Would it be a good idea to create gil_scoped_release once for the whole application scope and in any function that wants to run python code add gil_scoped_acquire?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
From documentation on gil locking, I couldn't get an understanding of how to use
gil_scoped_release
andgil_scoped_acquire
correctly.From this test I could understand that you have to
gil_scoped_release
once before running multiple threads and thengil_scoped_acquire
in each thread and it works correctly in my application.pybind11/tests/test_embed/test_interpreter.cpp
Lines 287 to 296 in 96b943b
My questions:
f
that executes some python code and makef
be thread safe?scoped_interpreter
that is created once for the whole application. Would it be a good idea to creategil_scoped_release
once for the whole application scope and in any function that wants to run python code addgil_scoped_acquire
?Beta Was this translation helpful? Give feedback.
All reactions