Skip to content

Commit

Permalink
Drop unnecessary exit stack
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyElaina authored and frankie567 committed Dec 8, 2024
1 parent e144d2a commit fedb69d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions httpx_ws/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 43,8 @@ def __init__(self, app: ASGIApp, scope: Scope) -> None:
async def __aenter__(
self,
) -> tuple["ASGIWebSocketAsyncNetworkStream", bytes]:
self.exit_stack = contextlib.AsyncExitStack()
task_group = await self.exit_stack.enter_async_context(
anyio.create_task_group()
)
task_group.start_soon(self._run)
self._task_group = await anyio.create_task_group().__aenter__()
self._task_group.start_soon(self._run)

await self.send({"type": "websocket.connect"})
message = await self.receive()
Expand All @@ -61,7 58,7 @@ async def __aenter__(

async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
await self.aclose()
await self.exit_stack.__aexit__(exc_type, exc_val, exc_tb)
await self._task_group.__aexit__(exc_type, exc_val, exc_tb)

async def read(
self, max_bytes: int, timeout: typing.Optional[float] = None
Expand Down

0 comments on commit fedb69d

Please sign in to comment.