Open mozesa opened 3 years ago
Is this something there is interest in? One couldn't convert the receive and receive_json methods to generators w/o breaking backwards compatibility I think, but maybe additional generator functions could be added? websocket.messages()
and websocket.json_messages()
or something? Or maybe this would over-complicate things...
Looks like starlette has adopted iter_text
, iter_bytes
and iter_json
so iter_messages
and iter_json
I think make the most sense. However, I need to think of how to indicate the websocket has disconnected.
Hello @pgjones,
I just would like to keep up this topic.
There was a discussion in which Nathaniel J. Smith mentioned that
async for
support forwebsockets
would be more pythonic.Currently:
The more idiomatic:
It would be great that the async for loop supports both
receive
andreceive_json
methods.Thanks for your help in advance.
Best Regards, András