From e7ec7bff6131e9234f239ce0a41878017a59cf91 Mon Sep 17 00:00:00 2001 From: Reto Tschuppert Date: Tue, 5 Nov 2024 08:28:22 -0500 Subject: [PATCH] Move websockets from legacy to asyncio --- src/onegov/websockets/cli.py | 2 +- src/onegov/websockets/client.py | 2 +- src/onegov/websockets/integration.py | 2 +- src/onegov/websockets/server.py | 5 ++--- tests/onegov/websockets/test_browser.py | 2 +- tests/onegov/websockets/test_client_server.py | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/onegov/websockets/cli.py b/src/onegov/websockets/cli.py index 2c93444a2c..f7a70494f2 100644 --- a/src/onegov/websockets/cli.py +++ b/src/onegov/websockets/cli.py @@ -5,7 +5,7 @@ import click from sentry_sdk import init as init_sentry -from websockets.legacy.client import connect +from websockets.asyncio.client import connect from onegov.core.cli import command_group, pass_group_context from onegov.websockets.client import authenticate diff --git a/src/onegov/websockets/client.py b/src/onegov/websockets/client.py index 6c958ab7f4..2bdf18645a 100644 --- a/src/onegov/websockets/client.py +++ b/src/onegov/websockets/client.py @@ -6,7 +6,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: from onegov.core.types import JSON_ro - from websockets.legacy.client import WebSocketClientProtocol + from websockets.client import WebSocketClientProtocol async def acknowledged(websocket: 'WebSocketClientProtocol') -> None: diff --git a/src/onegov/websockets/integration.py b/src/onegov/websockets/integration.py index e35662f382..6e24efadf1 100644 --- a/src/onegov/websockets/integration.py +++ b/src/onegov/websockets/integration.py @@ -6,7 +6,7 @@ from onegov.websockets.client import broadcast from urllib.parse import ParseResult from urllib.parse import urlparse -from websockets.legacy.client import connect +from websockets.asyncio.client import connect from typing import Any diff --git a/src/onegov/websockets/server.py b/src/onegov/websockets/server.py index 3a6817d4d0..040dacc955 100644 --- a/src/onegov/websockets/server.py +++ b/src/onegov/websockets/server.py @@ -11,8 +11,7 @@ from itsdangerous import BadSignature, Signer from markupsafe import escape from websockets.exceptions import ConnectionClosed, InvalidOrigin -from websockets.legacy.protocol import broadcast -from websockets.legacy.server import WebSocketServerProtocol, serve +from websockets.server import WebSocketServerProtocol, serve, broadcast from onegov.chat.collections import ChatCollection from onegov.chat.utils import param_from_path @@ -30,7 +29,7 @@ from sqlalchemy.orm import Session from websockets import Headers - from websockets.legacy.server import HTTPResponse + from websockets.asyncio.server import HTTPResponse from onegov.chat.models import Chat from onegov.core.types import JSONObject, JSONObject_ro diff --git a/tests/onegov/websockets/test_browser.py b/tests/onegov/websockets/test_browser.py index f7cec4c7d5..8207be202b 100644 --- a/tests/onegov/websockets/test_browser.py +++ b/tests/onegov/websockets/test_browser.py @@ -3,7 +3,7 @@ from onegov.websockets.client import status from pytest import mark from tests.onegov.websockets.conftest import WebsocketsRoot -from websockets import connect +from websockets.asyncio.client import connect @mark.asyncio diff --git a/tests/onegov/websockets/test_client_server.py b/tests/onegov/websockets/test_client_server.py index 6b0b88547f..7671429bfb 100644 --- a/tests/onegov/websockets/test_client_server.py +++ b/tests/onegov/websockets/test_client_server.py @@ -7,7 +7,7 @@ from onegov.websockets.client import status from pytest import mark from pytest import raises -from websockets import connect +from websockets.asyncio.client import connect @mark.asyncio