Skip to content

Commit 587298f

Browse files
alangenfeldPedramNavid
authored andcommitted
[dagster webserver] fix websockets on py3.11 (#19328)
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
1 parent 7af9a7d commit 587298f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

python_modules/dagster-webserver/dagster_webserver/graphql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async def graphql_ws_endpoint(self, websocket: WebSocket):
182182
"""
183183
tasks: Dict[str, Task] = {}
184184

185-
await websocket.accept(subprotocol=GraphQLWS.PROTOCOL)
185+
await websocket.accept(subprotocol=GraphQLWS.PROTOCOL.value)
186186

187187
try:
188188
while (

python_modules/dagster-webserver/dagster_webserver_tests/test_subscriptions.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import gc
22
import sys
33
from contextlib import contextmanager
4+
from typing import Iterator
45
from unittest import mock
56

67
import objgraph
@@ -36,7 +37,7 @@
3637

3738

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

4243
with WorkspaceProcessContext(
@@ -82,14 +83,15 @@ def example_job():
8283
example_op()
8384

8485

85-
def test_event_log_subscription():
86+
def test_event_log_subscription() -> None:
8687
with instance_for_test() as instance:
8788
run = example_job.execute_in_process(instance=instance)
8889
assert run.success
8990
assert run.run_id
9091

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

0 commit comments

Comments
 (0)