Skip to content

Commit

Permalink
[dagster webserver] fix websockets on py3.11 (#19328)
Browse files Browse the repository at this point in the history
another place effected by
python/cpython#100458

the string `<GraphQLWS.PROTOCOL: 'graphql-ws'>` was being sent instead
of `graphql-ws`

## How I Tested These Changes

added assert to test that would have caught this
  • Loading branch information
alangenfeld authored and PedramNavid committed Jan 26, 2024
1 parent 7af9a7d commit 587298f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async def graphql_ws_endpoint(self, websocket: WebSocket):
"""
tasks: Dict[str, Task] = {}

await websocket.accept(subprotocol=GraphQLWS.PROTOCOL)
await websocket.accept(subprotocol=GraphQLWS.PROTOCOL.value)

try:
while (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import gc
import sys
from contextlib import contextmanager
from typing import Iterator
from unittest import mock

import objgraph
Expand Down Expand Up @@ -36,7 +37,7 @@


@contextmanager
def create_asgi_client(instance):
def create_asgi_client(instance) -> Iterator[TestClient]:
yaml_paths = [file_relative_path(__file__, "./workspace.yaml")]

with WorkspaceProcessContext(
Expand Down Expand Up @@ -82,14 +83,15 @@ def example_job():
example_op()


def test_event_log_subscription():
def test_event_log_subscription() -> None:
with instance_for_test() as instance:
run = example_job.execute_in_process(instance=instance)
assert run.success
assert run.run_id

with create_asgi_client(instance) as client:
with client.websocket_connect("/graphql", GraphQLWS.PROTOCOL) as ws:
assert str(ws.accepted_subprotocol) == "graphql-ws"
start_subscription(ws, EVENT_LOG_SUBSCRIPTION, {"runId": run.run_id})
gc.collect()
assert len(objgraph.by_type("async_generator")) == 1
Expand Down

0 comments on commit 587298f

Please sign in to comment.