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

aiohttp do not work with QEventLoop #61

Closed inzem77 closed 8 years ago

inzem77 commented 8 years ago

Hello! I am writing Qt web socket chat. I have next code of function:

async def master():
    with aiohttp.ClientSession() as session:# make session
        async with session.post('http://127.0.0.1:8080', data={'nickname': 'Admin'}) as response:
            assert response.status == 200
            print(await response.text())

        async with session.ws_connect('http://127.0.0.1:8080/127.0.0.1/ws/') as ws:
            async for msg in ws:
                if msg.tp == aiohttp.MsgType.text:
                    print(msg.data)

This function works with loop = asyncio.get_event_loop() but does not works QEventLoop

I am using version aiohttp==0.20.2, asyncio==3.4.3, Quamash==0.5.4, Python3.5

harvimt commented 8 years ago

Is this on windows?

inzem77 commented 8 years ago

No, it is on linux Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty

harvimt commented 8 years ago

Full error message?

inzem77 commented 8 years ago

i do not have error. If i use asyncio.get_event_loop() script send post request, if i use QEventLoop script do not send post request. Full script read on http://pastebin.com/aR2JUN2u

harvimt commented 8 years ago

you should be doing asyncio.set_event_loop(loop) (where loop is instance of QEventLoop)

inzem77 commented 8 years ago

Ui form file http://pastebin.com/SQGKA7E6

inzem77 commented 8 years ago

it is working! Thank you!