-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add an IOError when send() is called on a closed connection #431
Conversation
specs/www.rst
Outdated
@@ -419,6 +428,15 @@ keys may be present, however. | |||
Disconnect - ``receive`` event | |||
'''''''''''''''''''''''''''''' | |||
|
|||
.. note:: |
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.
For websockets the event had additional information, namely the code
. Should we specify that the exception MUST have a code
attribute?
Can a raise a strong concern about this proposal. We use We're very happy with it, and this change would be highly disruptive. It's also not clear how this resolves the issues linked to on the ticket… If I'm running a long running task, I want to listen for |
You'd still be able to detect a disconnect my catching an
Let me see. I assume you don't care where or how you are notified of the disconnect, but you do want to be notified. Two options:
I like the second option. It makes sense to me that any time you try to interact with a client that is disconnected, be it sending or receiving data, you would be notified (via an error) that the client is disconnected. It's then up the user / framework to determine which of the two interactions they use. |
I do not believe we discussed deprecating the disconnect message at all, merely raising an error when someone tries to |
@andrewgodwin you are right and did not misunderstand, we had not explicitly discussed it. I felt it made sense to make |
OK, only one more nit now - the spec doc has two empty lines before each header and you have just one. Fix that and we can merge it in, I think. |
Done! Can we do a minor spec version bump after this so that frameworks can know if the server supports this? |
Yes, I think that would be appropriate - I'll add one in after this is merged. |
Applications may catch this exception and do cleanup work before | ||
re-raising it or returning with no exception. | ||
Servers must be prepared to catch this exception if they raised it and | ||
should not log it as an error in their server logs. |
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.
@andrewgodwin Isn't an update to this chapter https://asgi.readthedocs.io/en/latest/specs/www.html#disconnect-receive-event-ws also necessary? I find it misleading with the actual context if someone is reading it and now knowing/understanding it derives from https://asgi.readthedocs.io/en/latest/specs/www.html#disconnected-client-send-exception
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.
No, they are not related to each other - the disconnect event is emitted when you call receive()
, and the disconnected error is if you try to call send()
once the other side has disconnected.
I'm happy to add more clarification there if you think it's still confusing.
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.
You're fully right, I've mixed up the things and I needed to give it a fresh look later on to catch up better on it.
I still think that if someone is looking up for infos/specs for WebSockets send events, it's unlikely that this person (if not reading the full page) will get that this could generate a IOError subclass exception.
The structure of the page does not make explicitly clear if the exception applies for both HTTP and WebSockets scope, that could be specified more.
Also (and this is more what my original thought in the first comment was), there could a short sentence/infobox/warning for every description of a send event that this could generate an exception...
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'll go into the spec and see if I can add a bit of explicit clarification!
Closes #66