Command line and GUI tools : need a single threading solution
Adrian Casey
news at outbacklinux.com
Tue Jan 11 03:25:48 EST 2005
Diez B. Roggisch wrote:
>> I'm thinking it may be possible to modify the command line tools to use
>> qt
>> threads instead of native python threads. Is this the way to go? Are
>> there other options?
>
> Why don't you use python threads in qt - I do so and so far it didn't make
> any troubles for me. And I would strongly advise against using qthreads
> with your commandline-tools, as these then would only run on machines
> where pyqt is installed - which opens a small part of "dependency hell"
> for your users.
>
I have a QThread which polls a queue object via queue.get(). The command
line tools spawn a number of threads each of which writes its output to
this queue using queue.put(). As soon as the gui gets something off the
queue, it creates a QCustomEvent and sets the data property with the data
read from the queue. My application has a customEvent() method which reads
the data item from the customEvent and processes it accordingly.
The odd thing is, I have a non-threaded version of the command line tools
which work 100% with the gui. The multi-threaded version of the command
line tools all work OK at the console - just not with the gui.
I will try your suggestion and replace my QCustomEvent mechanism with a
plain python queue.
More information about the Python-list
mailing list