Запустить цикл событий asyncio, встроенный в поток ⇐ C++
-
Гость
Запустить цикл событий asyncio, встроенный в поток
I have a Qt application which uses pybind to embed python plugins providing some kind of handlers. From what I have read online gluing the event loops is nearly impossible. Now I wonder if it is possible to run an asyncio event loop in a c++ background thread and call gather in other threads (main or others, the scripts in c++ are called threaded, while the GIl serialized them again).
I think the question boils down to the following: if the c++ thread runs an asyncio eventloop, does it hold the GIL or does it release it while it idles?
If not I'll end up in a deadlock.
If it does in theory the threads in C++ could enter the python space and call gather. Which is nice.
Then again this throws the question if gather locks the GIL, which would defeat the purpose because other c++ threads would not be able to enter the Python space and effectively it would behave the same as if I would not have used asyncio at all.
Источник: https://stackoverflow.com/questions/781 ... -in-thread
I have a Qt application which uses pybind to embed python plugins providing some kind of handlers. From what I have read online gluing the event loops is nearly impossible. Now I wonder if it is possible to run an asyncio event loop in a c++ background thread and call gather in other threads (main or others, the scripts in c++ are called threaded, while the GIl serialized them again).
I think the question boils down to the following: if the c++ thread runs an asyncio eventloop, does it hold the GIL or does it release it while it idles?
If not I'll end up in a deadlock.
If it does in theory the threads in C++ could enter the python space and call gather. Which is nice.
Then again this throws the question if gather locks the GIL, which would defeat the purpose because other c++ threads would not be able to enter the Python space and effectively it would behave the same as if I would not have used asyncio at all.
Источник: https://stackoverflow.com/questions/781 ... -in-thread
Мобильная версия