-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement aiohttp.web websockets #220
Conversation
The code is fully covered! |
try: | ||
msg = yield from self._reader.read() | ||
except Exception as exc: | ||
raise WebSocketClosed(code=None, message=str(exc)) from exc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we should catch this exception, or we should make distinction
- protocol violation, like binary format errs
- client disconnection exception, i think this exception should be re-raised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't exception.__cause__
enouth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't matter, up to you. i think it should act similar to ClientDisconnectedError exception from normal http handler.
i like implementation! we just need better closing procedure. |
Please take a look: I've chosen You can override it by catching error directly but if you don't do this Do you agree with |
Sorry, I don't follow |
Yet another issue: what if web handler will create tasks those will wait for |
whenever i get GeneratorExit, it happens during process termination. during normal work we should never get GeneratorExit, in most cases it is indicator of something totally wrong.
|
i think we need WebSocketDisconnected exception and it should be DisconnectedError.
|
i don’t think it is good idea. from my experience with websockets, it is usually require 2 tasks one for reading and one for writing.
|
…adding origins also).
…, inherit WebClosedError from DisconnectedError instead of GeneratorExit
@fafhrd91 please review again. |
Server should have the single task for reading websocket messages. |
|
||
# log access | ||
self.log_access(message, None, resp_msg, self._loop.time() - now) | ||
except DisconnectedError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- this will catch disconnects from aiohttp.client
ServerHttpProtocol.start()
already handles ClientDisconnectedError, change start()
lgtm, except two notes regarding exceptions. |
…, get rid of checking for disconnection in web.RequestHandler
Exceptions are fixed. On Sat, Jan 3, 2015 at 8:49 PM, Nikolay Kim notifications@github.com
Thanks, |
Please review again. |
awesome! :) lgtm |
Implement aiohttp.web websockets
@fafhrd91 thanks for reviews |
Hi.
I've made websockets support in
aiohttp.web
.The code still has no full test coverage but basic tests are passed.
Please review.