Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
6f83e07e
Commit
6f83e07e
authored
5 years ago
by
Vincent Texier
Committed by
Vincent Texier
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[enh]
#58
enhance client class
parent
32488928
No related branches found
No related tags found
2 merge requests
!94
Merge dev into master for release 0.56.0
,
!84
#58: WS2P support
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
duniterpy/api/client.py
+35
-35
35 additions, 35 deletions
duniterpy/api/client.py
with
35 additions
and
35 deletions
duniterpy/api/client.py
+
35
−
35
View file @
6f83e07e
...
...
@@ -82,23 +82,24 @@ async def parse_response(response: ClientResponse, schema: dict) -> Any:
class
WSConnection
:
"""
From the documentation of the aiohttp_library, the web socket connection
await ws_connection = session.ws_connect()
should return a ClientWebSocketResponse object...
https://docs.aiohttp.org/en/stable/client_quickstart.html#websockets
In fact, aiohttp.session.ws_connect() returns a aiohttp.client._WSRequestContextManager instance.
It must be used in a with statement to get the ClientWebSocketResponse instance from it (__aenter__).
At the end of the with statement, aiohttp.client._WSRequestContextManager.__aexit__ is called
and close the ClientWebSocketResponse in it.
await with ws_connection as ws:
await ws.receive_str()
"""
# From the documentation of the aiohttp_library, the web socket connection
#
# await ws_connection = session.ws_connect()
#
# should return a ClientWebSocketResponse object...
#
# https://docs.aiohttp.org/en/stable/client_quickstart.html#websockets
#
# In fact, aiohttp.session.ws_connect() returns a aiohttp.client._WSRequestContextManager instance.
# It must be used in a with statement to get the ClientWebSocketResponse instance from it (__aenter__).
# At the end of the with statement, aiohttp.client._WSRequestContextManager.__aexit__ is called
# and close the ClientWebSocketResponse in it.
#
# await with ws_connection as ws:
# await ws.receive_str()
#
def
__init__
(
self
,
connection
:
_WSRequestContextManager
)
->
None
:
"""
Init WSConnection instance
...
...
@@ -155,8 +156,7 @@ class WSConnection:
async
def
init_connection
(
self
):
"""
Mandatory for aiohttp library to avoid the use of the with statement
Mandatory for aiohttp library in order to avoid the usage of the
'
with
'
statement
:return:
"""
self
.
connection
=
await
self
.
_connection
.
__aenter__
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment