Hi,

this is not a Pyside/PyQT bug. This is about Python and the
beloved-and-hated GIL (https://wiki.python.org/moin/GlobalInterpreterLock).

By spawning a lot of threads (like ThreadPoolExecutor does) you are
preventing the UI thread to refresh because there can't be more than one
thread at a time running python code.

To circumvent this, you can put some microsleeps like sleep(0.1) here and
there (so you give the thread scheduler to eventually allocate time for the
UI thread), you can build a synchronization strategy for the threads to
call QApplication.processEvents() in the main thread, or use
multiprocessing instead of threading (that complicates things and,
depending of the problem you have, can even slow down you multithreaded
algorithm).

Hope this helps,
David.


2014-12-10 7:07 GMT+01:00 iMath <[email protected]>:

> I think the user interface shouldn't be freezed when using
> concurrent.futures.ThreadPoolExecutor here, but it doesn't meet my
> expectations,anyone can explain why ? any other solutions here to not let
> user interface freezed?‍
>
> code is here
>
> http://stackoverflow.com/questions/27393533/user-interface-freezed-when-using-concurrent-futures-threadpoolexecutor
> ‍
> <http://stackoverflow.com/questions/27393533/user-interface-freezed-when-using-concurrent-futures-threadpoolexecutor>
>
> _______________________________________________
> PySide mailing list
> [email protected]
> http://lists.qt-project.org/mailman/listinfo/pyside
>
>


-- 
David "kraptor" Anes Alcolea
* @kraptor <http://twitter.com/kraptor> @simlaps
<http://twitter.com/simlaps>
* linkedin.com/in/davidanes
* kraptor.com | simlaps.com | 900grados.es
<http://simlaps.com>
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to