[PySide] decorator blocking thread signal?

Frank Rueter | OHUfx frank at ohufx.com
Wed Jan 18 02:12:45 CET 2017


Hi all,

this may be a pure python question or QT related, I'm not sure:
I am having trouble with a decorated function not reporting back to the 
main thread to drive progress bars etc.
When I remove the decorator and use the respective code directly in the 
function in question it all works fine.

My code looks sort of like this (heavily simplified):

    class ThreadManager(object):
         def __init__(self, parent):
             self.worker = Worker()
             self.workerThread = QtCore.QThread(parent)
             self.worker.moveToThread(self.workerThread)

         def start(self):
             self.workerThread.start()

    class Worker(QtCore.QObject):
         def myMethod(self):
                 someClassInstance.doHeavyLifting()



In my main code I connect signals from *someClassInstance* that indicate 
progress during the heavy lifting, so that they drive progress bars in 
the UI.
So far so good.

Now I am wanting to use a decorator on *myMethod(self)*, i.e.:

    class Worker(QtCore.QObject):

         @testDec
         def myMethod(self):
                 someClassInstance.doHeavyLifting()



where testDec looks like this:

    def testDec(fn):
         def addTest(self):
             print 'inside decorator', self
             fn(self)
         return addTest


The moment I do that, the threaded process does not report back to the 
main thread, so the progress bars sit at 0% until the process returns, 
then jump to 100%

What am I missing?

Cheers,
frank


-- 
ohufxLogo 50x50 <http://www.ohufx.com> 	*vfx compositing 
<http://ohufx.com/compositing.html> | *workflow customisation and 
consulting <http://ohufx.com/customising.html>* *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20170118/b4923bdd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ohufxLogo_50x50.png
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20170118/b4923bdd/attachment.png>


More information about the PySide mailing list