[PyQt] moveToThread() does not cope with functools.partial

Phil Thompson phil at riverbankcomputing.com
Mon Apr 29 13:06:55 BST 2013


On Mon, 29 Apr 2013 13:44:09 +0200, Giuseppe Corbelli
<giuseppe.corbelli at copanitalia.com> wrote:
> On 23/04/2013 17:52, Phil Thompson wrote:
>>>>> Please see the minimal test code below. In short connecting a signal
>> to
>>>> a
>>>>> functools.partial slot breaks the expected moveToThread behaviour.
>>>>> Reasonable, I'd say, once you think about it. I'm just asking some
>>>>> suggestion
>>>>> about how this issue can be addressed. I thought about
reimplementing
>>>> some
>>>>> signal class with a connect_partial method that stores bound args.
>>>>> Python 2.7.3, Qt 4.8.2, PyQt 4.10 on Linux.
>>>>
>>>> Should be fixed in tonight's PyQt4 snapshot.
>>>
>>> I'm curious to understand how you fixed it. Can I ask for a diff or
some
>>> other
>>> pointer to look at?
>>
>> Look at get_receiver() in qpy/QtCore/qpycore_pyqtboundsignal.cpp. It
just
>> strips off the functools.partial wrappers until it gets to the QObject.
>> The
>> proxy that is created is then moved to the same thread as the QObject.
> 
> Works correctly with pyqtSignal.
> I'm not able to reproduce the desired behaviour with
> QtCore.QObject.connect.
> 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.

Phil


More information about the PyQt mailing list