[QGIS-Developer] asyncio in plugins?

David Marteau dmarteau at 3liz.com
Tue Mar 23 13:14:18 PDT 2021


You should be aware that call to Qgis C/C++ api from Python hold the GIL 
and may prevent custom python threads  to run.

Le 23/03/2021 à 21:06, Sebastian M. Ernst a écrit :

> Hi David,
>
> I suspected this much. In theory, I can move the event loop into a
> separate thread [1, 2] - this should allow QGIS' event loop to continue
> running and accepting input etc. I am *guessing* that this can be made
> work. Question: Has someone around here actually tried it before?
>
> Best regards,
> Sebastian
>
>
> 1: https://gist.github.com/lars-tiede/01e5f5a551f29a5f300e
> 2:
> https://docs.python.org/3/library/asyncio-eventloop.html#executing-code-in-thread-or-process-pools
>
>
> Am 23.03.21 um 20:47 schrieb David Marteau:
>> Hi,
>>
>> Asynchronous python code with asyncio assume that you have an ioloop
>> running in a blocking way in your python code:
>> that means that no other code (in the same thread) cannot run
>> concurrently with your async tasks while your loop is running.
>>
>> David
>>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list