Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81528

Re: Fwd: Python Signal/Slot + QThred code analysis

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 <juan0christian@gmail.com>
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 <CAAp0bGttki1B=1q5SX_C39L_dRB22YOQiTbVxdvo4jSee0srcw@mail.gmail.com> <CAAp0bGsgMTK7MS1Wvh13304et7Bb7XUyfZTU8ZmF2++BuLj7dw@mail.gmail.com> <5473E188.5020608@gmail.com> <CAAp0bGtYCEWNLV7tnR6O5N706_3AkO9XRBs1pNP8TCxfctUyow@mail.gmail.com> <5474A333.2090207@mrabarnett.plus.com> <CAAp0bGsGLsWoXQnqFYN3KLeUsmcD5ujF80sasM16wx70zQ1xUA@mail.gmail.com> <CAAp0bGvhhWcLO76UQ+nXZuhazjJr9wsjwBkuCX78O4K=em9wuQ@mail.gmail.com> <5474C889.5090503@mrabarnett.plus.com>
From Juan Christian <juan0christian@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16296.1416951394.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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?

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Fwd: Python Signal/Slot + QThred code analysis Juan Christian <juan0christian@gmail.com> - 2014-11-25 21:36 +0000
  Content-Type (was: Fwd: Python Signal/Slot + QThred code analysis) "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-26 01:49 +0100

csiph-web