Skip to content

Commit

Permalink
Using _wait_closed.is_set() to determine if we need to wait or close …
Browse files Browse the repository at this point in the history
…the transport
  • Loading branch information
leszekhanusz committed Jul 15, 2024
1 parent 170846f commit 9a10f0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 4 additions & 3 deletions gql/transport/aiohttp_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@ async def _fail(self, e: Exception, clean_close: bool = True) -> None:

if self.close_task is None:

if self.websocket is None:
log.debug("_fail started with self.websocket == None -> already closed")
if self._wait_closed.is_set():
log.debug("_fail started but transport is already closed")
else:
self.close_task = asyncio.shield(
asyncio.ensure_future(self._close_coro(e, clean_close=clean_close))
Expand All @@ -984,7 +984,8 @@ async def close(self) -> None:
async def wait_closed(self) -> None:
log.debug("wait_close: starting")

await self._wait_closed.wait()
if not self._wait_closed.is_set():
await self._wait_closed.wait()

log.debug("wait_close: done")

Expand Down
3 changes: 0 additions & 3 deletions tests/test_aiohttp_websocket_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,6 @@ async def test_subscribe_on_closing_transport(event_loop, server, subscription_s


@pytest.mark.asyncio
@pytest.mark.skip(
reason="This test hangs with WebsocketsTransport or AIOHTTPWebsocketsTransport"
)
@pytest.mark.parametrize("server", [server_countdown], indirect=True)
@pytest.mark.parametrize("subscription_str", [countdown_subscription_str])
async def test_subscribe_on_null_transport(event_loop, server, subscription_str):
Expand Down

0 comments on commit 9a10f0d

Please sign in to comment.