[Qgis-developer] Bug? Python plug-in threadS seem to run only when Python console is busy.

Mikhail Titov mlt at gmx.us
Tue Jul 24 12:51:31 PDT 2012


Mikhail Titov <mlt-0UDz38MK/Mo at public.gmane.org> writes:

> It seems that the thread I create in my plug-in is mostly dormant unless
> I have something like time.sleep(alot) running in Python console. Is it
> normal? I even tried to start QThread with QThread.HighPriority with the
> same result:(

I'm not sure whether it is buffered IO or actually dormant thread
causing all the troubles.

The ugly workaround just to make it ticking is to set up 5 seconds
QTimer in main GUI thread after auxiliary thread is started and use
time.sleep(10) and QCoreApplication.instance().processEvents() in
timeout handling slot. The GUI does block during that thus rendering
entire idea unusable.

> The module itself runs just fine when started outside of QGIS.
>
> Am I not supposed to create threads in python plug-ins? I thought it
> would be better rather than trying to dig around QCoreApplication to
> process events so GUI is not frozen.

The bottom line is to create C++ plug-ins for multi-threaded tasks :(

> I'm running OSGeo4W versions of QGIS 1.8 on Windows XP SP3 32 bit if it
> matters.

It happens on GNU/Linux is well.

-- 
Mikhail


More information about the Qgis-developer mailing list