Fwd: Python Signal/Slot + QThred code analysis

Michael Torrie torriem at gmail.com
Fri Nov 28 17:38:16 CET 2014

On 11/28/2014 06:06 AM, Juan Christian wrote:
> 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?

Yes you can pass objects through signals.  You could pass a dict, or an
instance of one of your own classes.  You could also go back to your
first architecture and pass in an Outpost class instance to the worker
thread when instantiating it, and then the worker could use the outpost
instance to perform the work, then pass it back to your handler through
the signal.

> 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.

Yeah sounds alright. I'm sure there are multiple ways of doing this that
would work.

More information about the Python-list mailing list