Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'correct.': 0.07; 'method.': 0.07; 'finished.': 0.09; 'subject:using': 0.09; 'api': 0.11; 'thread': 0.14; 'blocking': 0.16; 'docs.': 0.16; 'fetch': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'grasp': 0.16; 'illustrates': 0.16; 'imo,': 0.16; 'subject:PyQt': 0.16; 'subject:user': 0.16; 'subject:when': 0.16; 'threads.': 0.16; 'url:qt-project': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'header:User-Agent:1': 0.23; 'lets': 0.24; 'define': 0.26; 'header :In-Reply-To:1': 0.27; 'function': 0.29; 'words': 0.29; 'url:wiki': 0.31; 'could': 0.34; 'form.': 0.35; 'but': 0.35; 'google': 0.35; 'done': 0.36; 'similar': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; "you're": 0.61; 'provide': 0.64; 'fire': 0.65; '8bit%:60': 0.84; 'asynchronous': 0.84 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Thu, 11 Dec 2014 23:07:22 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor References: <7e85a815-fd77-417a-9a5c-20537a83afcf@googlegroups.com> In-Reply-To: <7e85a815-fd77-417a-9a5c-20537a83afcf@googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418364458 news.xs4all.nl 2878 [2001:888:2000:d::a6]:58634 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82412 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