WebSocket session without a context manager? #39
Answered
by
frankie567
davidbrochart
asked this question in
Q&A
-
aconnect_ws is defined as an async context manager, that yields an AsyncWebSocketSession, which can then be closed. But there is no way to easily create such a session without a context manager AFAIU (for manually closing it). from contextlib import AsyncExitStack
from httpx_ws import aconnect_ws
async def main():
async with AsyncExitStack() as exit_stack:
ws = aconnect_ws("my_url")
websocket = await exit_stack.enter_async_context(ws)
_exit_stack = exit_stack.pop_all()
...
await _exit_stack.__aexit__() |
Beta Was this translation helpful? Give feedback.
Answered by
frankie567
Jul 11, 2023
Replies: 1 comment 1 reply
-
Didn't we discussed this some time ago ? ➡️ #11 😄 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
davidbrochart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Didn't we discussed this some time ago ? ➡️ #11 😄