IMHO if you remove the sleep(5), if it still works sometimes, it will work every time. If a sent signal does not find slot, it just "fades away". That is my understanding how it works. And if the "sleep" between emitting the signal and receiving it is long enough, it will always fail. Try it with sleep(1000) and with sleep(1) and tell us what happens.
On Monday 08 April 2013 21:26:16 Lucas Tanure wrote: Could you use the queue in python ? with Queue.get([block[, timeout]]) ? Lucas A. Tanure Alves +55 (19) 88176559 On Mon, Apr 8, 2013 at 6:59 PM, William Dias <[email protected]> wrote: Hi, Tibold. Thanks for your reply. If I first move my worker to the new thread and then make the connection should it work? According to the documentation, it would use an auto-connection and since emitter and receiver don't have the same thread affinity, it would create a queued connection. Is it right? Best, 2013/4/8 Tibold Kandrai <[email protected]> Hi, I think you’ll have to use queued connection when you connect the photoStatus signal to the photoStatus slot. See: http://qt-project.org/doc/qt-4.8/threads-qobject.html#signals-and-slots- across-threads Cheers, Tibold From: [email protected] [mailto:[email protected]] On Behalf Of William Dias Sent: 2013 April 08, Monday 17:01 To: [email protected] Subject: [PySide] Signal emitted on a worker thread not being received by main thread Hi, I am facing an intermittent problem with my PySide application. I have a GUI that spawns several threads that are responsible for sending photos to a web server. The threads are created as shown bellow: photoConnectionThread = QThread() photoConnectionObject = http_connection.PhotoConnection(self.filename) photoConnectionObject.photoStatus.connect(self.photoStatus) photoConnectionObject.moveToThread(photoConnectionThread) photoConnectionThread.started.connect(photoConnectionObject.work) photoConnectionThread.finished.connect(self.threadFinished) photoConnectionThread.start() My worker thread tries to upload a photo only once and then emits a signal to the main thread so that the status can be updated in a database. def work(self): logger.info("photo object created on thread " + str(self.thread())) status = sendPhoto(self.filename) self.photoStatus.emit(self.filename, status) QThread.sleep(5) logger.info("exiting thread " + str(self.thread())) self.thread().exit(0) The problem is that, sporadically, the main thread does not receive the signal and consequently doesn't get the status updated. Does anybody have any idea why this is happening? I am using: Python 2.7 PySide 1.1.1 Windows 7 Sean Fisk <[email protected]> Thank you! _______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
