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

Disable IOCPProactorLoop on Windows #45

Open Insoleet opened 9 years ago

Insoleet commented 9 years ago

Hi

Because of compatibility problems between aiohttp and the ProactorEventLoop ( http://stackoverflow.com/questions/23203874/does-the-aiohttp-python-library-in-windows-support-https ) it'd be great if we could use the "default loop" on windows.

Do you think this is possible ?

Insoleet commented 9 years ago

Ok it seems that forcing the import of the SelectorEventLoop in the __init__.py of quamash :

"""
if os.name == 'nt':
    from . import _windows
    _baseclass = _windows.baseclass
else:"""
from . import _unix
_baseclass = _unix.baseclass

I can avoid using the proactor event loop.

What would be the best way to implement a choice on the event loop to use ? I'm ready to send a PR.

harvimt commented 9 years ago

We like IOCP because it supports subprocess execution.

Some toggle though might be good. On Sep 17, 2015 05:45, "Insoleet" notifications@github.com wrote:

Ok it seems that forcing the import of the SelectorEventLoop in the init.py of quamash : """ if os.name == 'nt': from . import _windows _baseclass = _windows.baseclass else:""" from . import _unix _baseclass = _unix.baseclass

I can avoid using the proactor event loop.

What would be the best way to implement a choice on the event loop to use ? I'm ready to send a PR.

— Reply to this email directly or view it on GitHub https://github.com/harvimt/quamash/issues/45#issuecomment-141070003.

Insoleet commented 9 years ago

As IOCP is not fully handled by asyncio before Python 3.5, I think it is definitely worth it.

harvimt commented 9 years ago

ok, so, the general idea is going to be to base QEventLoop on asyncio.BaseEventLoop (or whatever it's called). then dynamically insert the right base class with

    QEventLoopIOCP = type('QEventLoopIOCP', (QEventLoop, IOCPEventLoop), {})

or (same thing different syntax)

    class QEventLoopIOCP(QEventLoop, IOCPEventLoop): pass
Insoleet commented 8 years ago

I need this feature for my sakia application. Aiohttp is not compatible with IOCPProactorEventLoop at all at the moment.

So, what is needed is the following :

How could this be done considering current quamash status of code ?


from ._unix import _SelectorEventLoop

if os.name == 'nt':
    from ._windows import ProactorEventLoop

@with_logger
class _QEventLoop(asyncio.BaseEventLoop):
  # Class data

class QEventLoopSelector(_QEventLoop, _SelectorEventLoop):
pass

if os.name == 'nt':
    class QEventLoopIOCP(_QEventLoop, _ProactorEventLoop):
    pass

Users would then have a choice between QEventLoopSelector and QEventLoopIOCP. Do you agree with the idea ? If so, I will do a pull request.

harvimt commented 8 years ago

There are several cleaner ways to get this to work I think, but I've pushed a gh45 branch for testing (slightly different names to follow a modifiers before format)

One would be to use the Qt functionality for subprocess handling instead of using the IOCP stuff built into python.

It seems like it should work on 3.5 though unless the add_reader and add_writer methods aren't being handled correctly.

On Thu, Jan 14, 2016 at 12:08 PM, Insoleet notifications@github.com wrote:

I need this feature for my sakia application. Aiohttp is not compatible with IOCPProactorEventLoop at all at the moment.

So, what is needed is the following :

  • Let windows users use SelectorEventLoop (it works on windows and is compatible with aiohttp)
  • Let windows users use IOCPProcatorEventLoop if they prefer

How could this be done considering current quamash status of code ?

from ._unix import _SelectorEventLoop if os.name == 'nt': from ._windows import ProactorEventLoop @with_loggerclass _QEventLoop(asyncio.BaseEventLoop):

Class data

class QEventLoopSelector(_QEventLoop, _SelectorEventLoop):pass if os.name == 'nt': class QEventLoopIOCP(_QEventLoop, _ProactorEventLoop): pass

Users would then have a choice between QEventLoopSelector and QEventLoopIOCP. Do you agree with the idea ? If so, I will do a pull request.

— Reply to this email directly or view it on GitHub https://github.com/harvimt/quamash/issues/45#issuecomment-171765548.

Insoleet commented 8 years ago

Should I test your branch with my application ? Or is it only for quamash dev team testing ?

harvimt commented 8 years ago

go ahead and test it. Now that the CI tests have passed it's about as stable as what's on PyPI.

On Fri, Jan 15, 2016 at 10:13 PM, Insoleet notifications@github.com wrote:

Should I test your branch with my application ? Or is it only for quamash dev team testing ?

— Reply to this email directly or view it on GitHub https://github.com/harvimt/quamash/issues/45#issuecomment-172163849.

Insoleet commented 8 years ago

After several days of testing, I think you can merge on master branch.

fraca7 commented 7 years ago

FYI I've been testing this branch as well for a few days at work and it seems pretty stable.

mgejke commented 7 years ago

Hi,

What's the status of the gh45 branch? Or is there another way to use the SelectorEventLoop on Windows?