Closed Electron4444 closed 3 weeks ago
I don't want to do this for two reasons:
Could you maybe add a keyword option to set which enables this. I'm gonna make a pull- request containing the proposal. I would just let this controlling optional parameter default to None but have it raise the exception if enabled. This would make handeling Connection Closes inside the handler function provided to serve way easier.
No. Good API design is about providing a good API, not about providing knobs to get every possible behavior.
The problem with the change that you're proposing is that a reader of the code cannot tell anymore what for message in websocket: ...
does. The reader needs to look at where the websocket object is defined. That's bad.
I purpose a slight change to the ServerConnection.aiter method, to raise the ConnectionClosed Exception on excepting the CloseConnectionOK Exception. This would lead to the funtionality documented in Patterns for the Producer to be true for the Consumer as well and enable the possibility for a server waiting on receiving messages to close the handler for the corresponding client more easily on a connection close