Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'finished,': 0.07; 'processing.': 0.07; 'callback': 0.09; 'http': 0.09; 'subject:using': 0.09; 'python': 0.11; 'gui': 0.12; 'thread': 0.14; 'blocking': 0.16; 'concurrency': 0.16; 'concurrent': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'subject:PyQt': 0.16; 'subject:user': 0.16; 'subject:when': 0.16; 'threads,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'header:User- Agent:1': 0.23; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'thus': 0.29; 'code': 0.31; 'usually': 0.31; 'probably': 0.32; 'core': 0.34; 'problem': 0.35; 'except': 0.35; 'but': 0.35; 'returning': 0.36; 'doing': 0.36; 'starting': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'simply': 0.61; 'kind': 0.63; 'real': 0.63; 'such': 0.63; 'within': 0.65; 'between': 0.67; 'fact,': 0.69; 'sharing': 0.69; '*and*': 0.84; 'asynchronous': 0.84; 'fact.': 0.84 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Thu, 18 Dec 2014 09:29:14 -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: <4f2a19ce-7642-4beb-9dd6-7771c6237a3f@googlegroups.com> In-Reply-To: <4f2a19ce-7642-4beb-9dd6-7771c6237a3f@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418920169 news.xs4all.nl 2832 [2001:888:2000:d::a6]:47078 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82638 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.