[PyKDE] QThread run() method not being called when start() is executed (PyQt4/ Windows XP)

Andreas Pakulat apaku at gmx.de
Tue Mar 6 00:08:26 GMT 2007


On 05.03.07 14:32:13, Tony Cappellini wrote:
> >Fix your code or post your code.
> >Sorry I can't give a more specific answer - a more specific question would
> >help.
> 
> Not sure how more specific I could get. The run() method isn't being
> invoked, and I don't know how to debug a thread issue.
> 
> As you requested, here's my code.
> 
> class ConvertThread(QThread):
>  def __init__(self,main):
>    QThread.__init__(self)
>    self.main = main
>    self.connect(self, SIGNAL('write'), self.main.write)
> 
>  def run(self):
>    self.str = ''
>    script=open('nm2g2.py').read()
>    globs = globals()
>    exec 'from nm2g2 import *' in globs
>    logging = globs['logging']
>    logging.basicConfig(stream=self, format='%(message)s')
>    main(['nm2g2.py','-v0']+self.files)
>    logging.critical('Conversion finished.')
>    self.exit(0)
> 
>  def write(self, s):
>    self.str += s
> 
>  def flush(self):
>    self.emit(SIGNAL('write'), self.str)
>    self.str = ''
[...] 
> The reasons I speculate that run() isn't getting called
> 
> 1. No output files are generated by the target application (the Python
> app being launched by the GUI)
> 
> 2. I've set breakpoints where self.convert.start() is called, and in
> NM2G2G.write() self.convert.start() is being executed, but
> NM2G2G.write() never gets called. Since NM2G2G.write() isn't getting
> called, I'm speculating that run() is never being called.

Well, of course not because nothing in your code calls flush and thus
the emitting of the write signal is never done. Also I'm not sure wether
its a good idea to have a signal and a function with the same name in
the ConvertThread class.

Andreas

-- 
You will be honored for contributing your time and skill to a worthy cause.




More information about the PyQt mailing list