Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'class,': 0.07; 'init': 0.07; 'subject: + ': 0.07; 'subject:code': 0.07; 'variables': 0.07; "'')": 0.09; '*args,': 0.09; '__init__': 0.09; 'arguments,': 0.09; 'expected.': 0.09; 'function,': 0.09; 'def': 0.12; 'itself.': 0.14; 'thread': 0.14; '**kwargs)': 0.16; '**kwargs):': 0.16; 'accepts': 0.16; 'emit': 0.16; 'guys,': 0.16; 'set,': 0.16; 'soup': 0.16; 'stuff.': 0.16; 'subject:analysis': 0.16; 'typeerror:': 0.16; 'when,': 0.16; 'trying': 0.19; "skip:' 30": 0.19; 'import': 0.22; 'separate': 0.22; 'creating': 0.23; 'now?': 0.24; 'guys': 0.24; 'subject:/': 0.26; 'skip:" 20': 0.27; 'values': 0.27; 'related': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'requests': 0.31; "skip:' 10": 0.31; 'file': 0.32; 'class': 0.32; 'stuff': 0.32; 'run': 0.32; 'another': 0.32; '(most': 0.33; 'skip:& 30': 0.33; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; "can't": 0.35; 'skip:s 30': 0.35; 'received:google.com': 0.35; 'done,': 0.36; 'right?': 0.36; 'doing': 0.36; 'so,': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'skip:b 40': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'signal': 0.60; 'subject:Fwd': 0.61; 'back': 0.62; 'here': 0.66 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=0+x/knmpAJCzry8pOed7reG3V6xjGg5bA2UKWCxU8zo=; b=NToo95bwdoPnVnW++wOlx1BPbQ4nENOBZthpG9+hUJjWK9hgQ3DWoZZ0BB4HnbIhIJ TpVsHnDMtSwwrYUQb9DnVL0sNL59LhN3GAH8KyXKHzAjdMk32ngGp+ui9EgHoAQzC+C2 kbqpOVWl0OQvD0Xlo+SbnFvX6xK20J37ZFxvMCVrYtUFq2lG4dDXJxnPo93QgeW5/NFs gsbcl02yDFF42tP6DRRPI06yB+VZJdcD2KIQHfW271jXJBQ7q3M85E61hd/deby16nEF itujRGSXHLgA+eQdYElE/WcuVijr/2X4LWKusIFtBi3M0WIIgt4kMvvgTfNXmLfevMi7 bxPQ== X-Received: by 10.152.23.103 with SMTP id l7mr29653900laf.92.1416951385184; Tue, 25 Nov 2014 13:36:25 -0800 (PST) MIME-Version: 1.0 References: <5473E188.5020608@gmail.com> <5474A333.2090207@mrabarnett.plus.com> <5474C889.5090503@mrabarnett.plus.com> From: Juan Christian Date: Tue, 25 Nov 2014 21:36:24 +0000 Subject: Re: Fwd: Python Signal/Slot + QThred code analysis To: python-list@python.org Content-Type: multipart/alternative; boundary=089e0158c318fa5f310508b5b38b 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: 122 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416951394 news.xs4all.nl 2906 [2001:888:2000:d::a6]:40240 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81528 --089e0158c318fa5f310508b5b38b Content-Type: text/plain; charset=UTF-8 So guys, I had to change to approach, I read that using Qt I can't do multiple inheritance. So my Outpost class can't be like 'Outpost(QObject, QThred)'. I had to change the code a bit: from PySide.QtCore import QObject, QThread, Signal import requests import bs4 class Worker(QThread): def __init__(self, url, *args, **kwargs): super().__init__(*args, **kwargs) self.trades = None self.posts = None self.url = url self.start() def run(self): soup = bs4.BeautifulSoup(requests.get(self.url).text) self.trades = soup.select('div.stat_box div.value')[0].get_text().replace(',', '') self.posts = soup.select('div.stat_box div.value')[1].get_text() return self class Outpost(QObject): received = Signal() def __init__(self, id64, *args, **kwargs): super().__init__(*args, **kwargs) worker = Worker('http://www.myurl.com/' + id64) self.received.emit(worker) So, what I see people doing is creating a 'Worker' class for thread related stuff and another separate class for the main stuff. So, let's see the problems: Traceback (most recent call last): File "D:/.../main.py", line 44, in output_slot outpost = Outpost('12345') File "D:\...\outpost.py", line 27, in __init__ self.received.emit(worker) TypeError: received() only accepts 0 arguments, 2 given! The URL is OK, I externally checked, and return the expected. So, what I'm trying to do here is call my Worker when outpost is instantiated, then the Worker call the site in the run function, and then set the variables and return itself. Back to the main class, I have the init where I instantiate the Worker and return it in the emit(). If I got it correctly, when I call the 'outpost.received.connect(IPSUM)', IPSUM will be execute when, and only when I have all values set, because in my Outpost class it will emit when it has everything done, did I get it right? OFF-TOPIC: You guys said that my emails had some trash HTML and strange stuffs, is it OK now? --089e0158c318fa5f310508b5b38b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable So guys, I had to change to approach, I read that using Qt I can't do m= ultiple inheritance. So my Outpost class can't be like 'Outpost(QOb= ject, QThred)'. I had to change the code a bit:

from PySide.QtCore import QObject, QThread, Signal
import reques= ts
import bs4


class Worke= r(QThread):
def __init__(self, url, *args, **kwargs):
super().__init__(*ar= gs, **kwargs)
self.trades =3D None
self.posts =3D None
self.url =3D url<= /div>
self.start()

def run(self):
soup =3D bs4.BeautifulSoup(req= uests.get(self.url).text)
self.trades =3D soup.select('div.stat_box di= v.value')[0].get_text().replace(',', '')
self.posts = =3D soup.select('div.stat_box div.value')[1].get_text()
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> return sel= f


class Outpost(QObject):
received = =3D Signal()

def __init__(self, id64, *args, **kwargs):
su= per().__init__(*args, **kwargs)
worker =3D Worker('http://www.myurl.com/' + id64)
self.received.emit(w= orker)

So, what I see people doing is creati= ng a 'Worker' class for thread related stuff and another separate c= lass for the main stuff.

So, let's see the pro= blems:

Traceback (most recent call last):
=C2=A0 File "D:/.../main.py", line 44, in output_slot
=C2=A0 =C2=A0 outpost =3D Outpost('12345')
=C2=A0 F= ile "D:\...\outpost.py", line 27, in __init__
=C2=A0 = =C2=A0 self.received.emit(worker)
TypeError: received() only acce= pts 0 arguments, 2 given!

The URL is OK, I e= xternally checked, and return the expected.

So, wh= at I'm trying to do here is call my Worker when outpost is instantiated= , then the Worker call the site in the run function, and then set the varia= bles and return itself.

Back to the main class, I = have the init where I instantiate the Worker and return it in the emit().

If I got it correctly, when I call the 'outpost= .received.connect(IPSUM)', IPSUM will be execute when, and only when I = have all values set, because in my Outpost class it will emit when it has e= verything done, did I get it right?

OFF-TOPIC: You= guys said that my emails had some trash HTML and strange stuffs, is it OK = now?
--089e0158c318fa5f310508b5b38b--