Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'subject: + ': 0.07; 'subject:code': 0.07; 'callback': 0.09; 'question.': 0.14; 'thread': 0.14; "wouldn't": 0.14; 'invokes': 0.16; 'redo': 0.16; 'reproduce': 0.16; 'scope.': 0.16; 'str),': 0.16; 'str,': 0.16; 'stuff,': 0.16; 'stuff.': 0.16; 'subject:analysis': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'possible,': 0.19; 'code,': 0.22; 'email addr:gmail.com>': 0.22; 'print': 0.22; 'load': 0.23; 'mind.': 0.24; 'sends': 0.24; 'pass': 0.26; 'subject:/': 0.26; 'michael': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'object.': 0.31; 'stuff': 0.32; 'problem': 0.35; 'done.': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'data,': 0.36; 'doing': 0.36; 'web,': 0.36; "i'll": 0.36; 'possible': 0.36; 'being': 0.38; 'fri': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'signal': 0.60; 'new': 0.61; 'subject:Fwd': 0.61; 'first': 0.61; 'more': 0.64; 'different': 0.65; 'fire': 0.65; 'here': 0.66; 'invalid': 0.68; 'risk': 0.72; 'asynchronous': 0.84; 'urls,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:from:date:message-id:subject:to :content-type; bh=CzLGjj+K0C/iB8fvYL6Hr7h3NmsG0Bm4UvRoDFwklTw=; b=Xaxckr/xb2PV5hHoj0PDW2HGdIJTukbzNGW7tU0b4cwjdM1sr17m9qTMS0Sc8c9Y1X W8+2JnooHUWyBrCDE5I61FZVIVB+3dxh4DP0Knel42PHdWPSc0Su25CU1/9E4GCRuWO8 oHXDSoxteuHx14ePu0QIhqvh0nwdlBnkdu0oDQzQB6o3p9O7Bdim1TvXIy0nKOsGz0PC U5JU0lOHZXUDNBdEC3D5rm2jvrWaADXq3gkf0RQyGIjJQBCbQCqZqb4ByEy0gr6S/Syv 4/h5l5ddiT46PNV6l9/5nOq0sjBE/70vWmQCq63/dVNTeFQ4trrpqE53fZAjrDMQ0j7t HXhg== X-Received: by 10.224.46.66 with SMTP id i2mr61857503qaf.72.1417180017120; Fri, 28 Nov 2014 05:06:57 -0800 (PST) MIME-Version: 1.0 References: <5473E188.5020608@gmail.com> <5474A333.2090207@mrabarnett.plus.com> <5474C889.5090503@mrabarnett.plus.com> <547545CF.60208@gmail.com> <5476A134.7050407@gmail.com> <5476A48C.1050607@gmail.com> <5477AB1E.3030609@gmail.com> <5477F4CE.2010701@gmail.com> From: Juan Christian Date: Fri, 28 Nov 2014 13:06:56 +0000 Subject: Re: Fwd: Python Signal/Slot + QThred code analysis To: python-list@python.org Content-Type: multipart/alternative; boundary=001a11c29e0a80ddc90508eaef7b 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: 72 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417180019 news.xs4all.nl 2894 [2001:888:2000:d::a6]:43038 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81679 --001a11c29e0a80ddc90508eaef7b Content-Type: text/plain; charset=UTF-8 On Fri Nov 28 2014 at 2:07:32 AM Michael Torrie wrote: Okay, here's a reworking of the code that invokes a new QThread instance each time. Note the QThread instance has to be bound to the MainWindow so that it won't be destroyed when it goes out of scope. Also the Worker thread sends a signal with the data, so there's no need to check worker.trades and risk it being invalid data. Perhaps this would be more what you had in mind. You may want to look into asynchronous I/O as well. That does not require threads at all. Fire off a request to load a url, and then get a callback when it's done. Now it's working like a charm without any freezes. I'll reproduce this 'Worker' for other stuffs that I need to call the web, but first I have a question. Which one would be better in performance, having a single 'Worker' to call all URLs, having inside this worker functions for each stuff, or having 3~5 different workers doing different stuff. In the end I'll only print the data when I have them all. The problem is that I would have a long new_value = Signal(QThread, str, str), with more then 10 values, is it possible to pass objects here like new_value = Signal(QThread, ObjA, ObjB, ...) so that in the 'create_topic' I would get the objects and call methods in order to get all the data? This approach would be better, because I may be adding more stuff and I wouldn't need to add tons and tons of new stuff in my signal, only one object. You don't need to redo the code, I just need to know if it's a 'good approach' and if it's possible, from here I can work my way. --001a11c29e0a80ddc90508eaef7b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Fri Nov 28 2014 at 2:07:32 AM Michael Torrie = <torriem@gmail.com> wrote: Okay, here's a reworking of the code that invokes a new QThread inst= ance
each time. Note the QThread instance has to be bound to the MainW= indow
so that it won't be destroyed when it goes out of scope. Als= o the
Worker thread sends a signal with the data, so there's no nee= d to check
worker.trades and risk it being invalid data.

Perha= ps this would be more what you had in mind.

You may want to look i= nto asynchronous I/O as well. That does not
require threads at all. F= ire off a request to load a url, and then get
a callback when it's = done.


Now it's working like a charm w= ithout any freezes. I'll reproduce this 'Worker' for other stuf= fs that I need to call the web, but first I have a question.

=
Which one would be better in performance, having a single 'W= orker' to call all URLs, having inside this worker functions for each s= tuff, or having 3~5 different workers doing different stuff. In the end I&#= 39;ll only print the data when I have them all.

Th= e problem is that I would have a long=C2=A0new_value =3D Signal(QThread, st= r, str), with more then 10 values, is it possible to pass objects here like= =C2=A0new_value =3D Signal(QThread, ObjA, ObjB, ...) so that in the 'cr= eate_topic' I would get the objects and call methods in order to get al= l the data?

This approach would be better, because= I may be adding more stuff and I wouldn't need to add tons and tons of= new stuff in my signal, only one object.

You don&= #39;t need to redo the code, I just need to know if it's a 'good ap= proach' and if it's possible, from here I can work my way.
--001a11c29e0a80ddc90508eaef7b--