Wenzel Jakob <wen...@inf.ethz.ch> added the comment:

Hi,

pybind11 developer here. A bit on context of our usage of this function:

Pybind11 supports some advanced GIL-related tricks that *require* access this 
function. For instance, pybind11 can intercept a Python function call on the 
`main()` thread and delete the associated thread state, launching a new thread 
and continuing Python execution there (with a newly created thread state).

Kind of crazy, but why is this useful? UI libraries. On some platforms, it is 
not legal to poll UI events on any thread other than the main thread. This 
means that it's impossible to implement a proper UI event loop because Python 
is hogging the main thread. With the functionality in pybind11's 
``gil_scoped_acquire``, I can launch an event polling loop on the main thread, 
continue running an interactive Python session on another thread, and even swap 
them back e.g. when the user interface is no longer needed.

Best,
Wenzel

----------
nosy: +wenzel

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37878>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to