Added Python 3.5 “async for” compat to websocket#543
Added Python 3.5 “async for” compat to websocket#543asvetlov merged 1 commit intoaio-libs:masterfrom
Conversation
|
uh, those test failures are no my fault. i fixed them in #544 |
|
triggering rebuild |
|
hmm, OK, now the error is: $ flake8 aiohttp
aiohttp/web_ws.py:297:19: F821 undefined name 'StopAsyncIteration'but this is wrong. of course this is an undefined name in python < 3.5, but as you’d have to call so i’ll just make flake8 shut up. |
|
Tests and documentation update are required |
|
i don’t seem to get this test to run. it hangs, don’t know why… |
|
In Travis log: |
|
i know, i just made a last-minute fix and didn’t run it after 😐 check the new one, that’s the real problem. |
401f1e3 to
48ae89e
Compare
|
Seems hangs on msg = await resp._reader.read()In yield from self._waiterIt stops there I guess... |
|
ya. why? |
|
Here is the part of the my testing in items = ['q1', 'q2', 'q3']
for item in items:
resp._writer.send(item)
msg = await resp._reader.read()
assert msg.tp == websocket.MSG_TEXT
assert item + '/answer' == msg.data
resp._writer.close()
msg = await resp._reader.read()
assert msg.tp == websocket.MSG_CLOSE
assert msg.data == 1000
assert msg.extra == ''
await closed
await resp.close()Server will not know if it need to send close message back. So you need to send close first or it will wait for Also, remember to |
|
thanks! you saved me quite some time. 🙇 i copied the test from elsewhere and adapted it … poorly. i hope this is it then! |
Instead of while True: msg = await ws.receive() ... elif msg.tp == web.MsgType.close: break do: async for msg in ws: ...
There was a problem hiding this comment.
Why do you need private attribute access. The test may use send() and receive() client response methods.
There was a problem hiding this comment.
eh, no idea, i copied stuff from elsewhere. what methods are you referring to?
There was a problem hiding this comment.
resp._writer.send(item) ?
I think he means _writer is a private attribute and should not be used in testing.
There was a problem hiding this comment.
sure. my question is what i should use instead
|
oh, sorry. i would have done it eventually 😅 |
Instead of
do: