PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor
Michael Torrie
torriem at gmail.com
Fri Dec 12 01:07:22 EST 2014
On 12/11/2014 08:20 PM, iMath wrote:
> 在 2014年12月11日星期四UTC+8下午1时25分41秒,Michael Torrie写道:
>> On 12/10/2014 09:52 PM, iMath wrote:
> "when it comes to I/O and GUIs, asynchronous calls are always better than threads."
>
> I cannot grasp your meaning here, IMO, asynchronous calls are done by using threads.
Not in your code. All your I/O calls are synchronous; they block until
they are finished. But if you mean that calling synchronous calls while
in a thread has a similar effect to an asynchronous call, you are
correct. But the way you're waiting for the threads to finish, you're
blocking your gui.
An asynchronous API lets you start long-running I/O calls and define a
function that is automatically called upon completion. In other words
it's event-driven. Qt may provide everything you need already in an
asynchronous form. Check the docs. And use google. Here's a link I
found from a google search that illustrates how to fetch a url in Qt
using an asynchronous method. You could fire off as many of these as
you want, then just wait for signals.
http://qt-project.org/wiki/Download_Data_from_URL
More information about the Python-list
mailing list