[PyKDE] really wierd qthread + emit issue

Matt Chambers chambers at imageworks.com
Wed Nov 22 00:54:12 GMT 2006


Using PyQt 4.0 and Qt 4.1.  I'm emitting a single from a QThread with a 
single argument.   About 50% of the time when  I catch
the signal and execute the slot function, the argument is a QMutex 
object, not the argument I emitted with the signal.

Here is my threads run() function.

    def run(self):
            while self.__running:
                job_name = None      
                self.__parent._q_mutex.lock()
                if len(self.__parent._q_queue) == 0:
                    _log.debug("Thread-%d waiting for data" % (self.__name))
                    self.__parent._q_empty.wait(self.__parent._q_mutex)
                else:
                    job_name = self.__parent._q_queue.pop(0)
                self.__parent._q_mutex.unlock()
               
                if job_name:
                    _log.debug("thread-%d parsing cue job log" % 
self.__name)
                    try:
                        cjob = 
cuejob.CueJob(job_name[0:job_name.find("-")],job_name)
                        cjob.profile()
                        self.emit(QtCore.SIGNAL("parsingComplete"),cjob)
                    except Exception,e:
                        _log.debug("Error parsing cue job: %s" % (e))
                       
            _log.debug("Thread Stopping")


Notice I'm emitting the signal with a cuejob.CueJob object, but from the 
slot, when I print the first argument, I get:
<PyQt4.QtCore.QMutex object at 0xf6b0b22c>

Matt




More information about the PyQt mailing list