harvimt / quamash

Implementation of the PEP 3156 event-loop (asyncio) api using the Qt Event-Loop
BSD 2-Clause "Simplified" License
265 stars 46 forks source link

fix _ProactorEventLoop initialization bug #53

Closed peterazmanov closed 9 years ago

peterazmanov commented 9 years ago

QtCore.QObject.__init__(self) and asyncio.ProactorEventLoop.__init__(self, _IocpProactor()) causes double initialization of asyncio.ProactorEventLoop, according to mro. Possibly related to #38.

aknuds1 commented 9 years ago

@harvimt Do you have a Windows machine to test this on? I don't understand without testing why asyncio.ProactorEventLoop would get double initialized though.

aknuds1 commented 9 years ago

Is it because QObject calls super().__init__() that asyncio.ProactorEventLoop gets double initialized? Difficult to tell without testing.

aknuds1 commented 9 years ago

I tested on OS X, AFAICT QObject does indeed call super().__init__() so that the next baseclass (ProactorEventLoop) gets initialized twice. So, in summing up, looks good to me.

peterazmanov commented 9 years ago

@aknuds1 I tested this on Windows 7 machine with Python 3.4

harvimt commented 9 years ago

I'm worried that this will be different depending on which Qt implementation is used. I suggest moving the object that can receive the signal into it's own object instead of subclassing QObject and ProactorEventLoop like I do in #29.

peterazmanov commented 9 years ago

@harvimt why _ProactorEventLoop (or any class in the quamash.QEventLoop hierarchy) needs inheritance from QObject? AFAICT, unix implementation is different in this regard.

harvimt commented 9 years ago

to receive Qt signals, but like I said a better implementation is a dedicated signal receiver object.

On Wed, Nov 18, 2015 at 3:39 AM, Peter Azmanov notifications@github.com wrote:

@harvimt https://github.com/harvimt why _ProactorEventLoop (or any class in the quamash.QEventLoop hierarchy) needs inheritance from QObject? AFAICT, unix implementation is different in this regard.

— Reply to this email directly or view it on GitHub https://github.com/harvimt/quamash/pull/53#issuecomment-157685679.

peterazmanov commented 9 years ago

@harvimt PyQt successfully connects signals to methods of non-QObject-subclass class. PyQt docs

harvimt commented 9 years ago

Sorry not receive or send, but declare. Only EventPoller needs to be a QObject, I fix this in https://github.com/harvimt/quamash/commit/847df31c184125c8d147d74d17b690218e0cec2c, (which is part of #29, which I never merged)

harvimt commented 9 years ago

I cherry-picked https://github.com/harvimt/quamash/commit/847df31c184125c8d147d74d17b690218e0cec2c, and updated the docstrings so flake8-docstrings stops bugging (new check they added), so this is fixed in master.