Запустить цикл событий asyncio, встроенный в потокC++

Программы на 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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»