PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

Michael Torrie torriem at gmail.com
Thu Dec 18 11:29:14 EST 2014


On 12/18/2014 04:16 AM, Mark Summerfield wrote:
> It looks to me that what you are doing is sharing a single core
> between your GUI and your processing. Threading isn't usually a good
> approach to Python concurrency that is CPU-bound.

Except that his code was not CPU-bound to begin with.  His real problem
is that his callback is starting *and* waiting for all the threads to do
their work without returning to the main loop, thus blocking the GUI.
As for the threads, they are I/O bound--he's simply trying to do
concurrent HTTP downloads.  So blocking in the GIL is not the issue
here.  In fact, in lieu of using proper asynchronous I/O, threading of
some kind is probably not a bad solution here, but he has to do it
within the Qt Framework, using signals to notify the GUI when a thread
is finished, or using a synchronization primitive such as a queue, as
recommended by your book in fact.



More information about the Python-list mailing list