Repository navigation
Conversation
Instead of instantiating a client object and calling connect(), you now call open_websocket(), which is an async context manager.
Closed
belm0
reviewed
Sep 18, 2018
|
|
||
|
|
||
| @asynccontextmanager | ||
| @async_generator |
Member
There was a problem hiding this comment.
I don't think the @async_generator belongs here, try removing it
@asynccontextmanager implies a generator that yields a single value
Contributor
Author
There was a problem hiding this comment.
According to the docs async_generator is required for compatibility with Python 3.5 (which is the minimum version specified in setup.py right now). Even with Python 3.6, contrary to what the docs say, it broke when I removed it.
|
|
||
| @asynccontextmanager | ||
| @async_generator | ||
| async def open_websocket_url(nursery, url, ssl_context=None): |
Member
There was a problem hiding this comment.
I believe you can make this a non-async, non-contextmanager function which simply defers to open_websocket() (literally return open_websocket(...))
Contributor
Author
There was a problem hiding this comment.
Ahh yes, you're right!
Contributor
Author
|
Merged directly to master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As mentioned in #24, the WebSocketClient class is a confusing and unnecessary part of the API. This PR replaces that class with a context manager. It also adds support for opening a WebSocket by URL.