[PyQt] moveToThread() does not cope with functools.partial
giuseppe.corbelli at copanitalia.com
Mon Apr 29 17:01:50 BST 2013
On 29/04/2013 14:06, Phil Thompson wrote:
>> Works correctly with pyqtSignal.
>> I'm not able to reproduce the desired behaviour with
>> Any suggestion? What I'm missing?
> I'm not making changes to old-style connections. It's a bug if there is
> anything that you can do with old-style connections that you can't do with
> new-style connections.
Found the reason, maybe worth changing pyqtSignal too. When checking slot
type, besides Method, Function and functools.partial might be a good idea to
check also anything that has a __call__ method, so that you can connect
correctly to an object instance.
As of pyqt snapshot-4.10.2-d9c6e01fe9ce you can connect to an object directly
(always referring to the __call__ method) but the thread affinity does not work.
Minimal sample code:
# -*- coding: utf-8 -*-
from PyQt4 import QtCore
logger = logging.getLogger('blah')
mysignal = QtCore.pyqtSignal()
logger.debug("__call__ %s", QtCore.QThread.currentThreadId())
logger.debug("call %s", QtCore.QThread.currentThreadId())
app = CApp(sys.argv)
app_thread = app.thread()
logger.info("Main thread ID %s", QtCore.QThread.currentThreadId())
thread = QtCore.QThread()
while not thread.isRunning():
a = CReceiver()
timer = QtCore.QTimer()
Get this output:
INFO:blah:Main thread ID 3075479232
WASP Software Engineer, Copan Italia S.p.A
Phone: +390303666318 Fax: +390302659932
E-mail: giuseppe.corbelli at copanitalia.com
More information about the PyQt