From 00ebbb7afe3aadc1fecc78268adc66b436d13fea Mon Sep 17 00:00:00 2001 From: Ro'e Katz Date: Wed, 24 Apr 2024 14:25:10 +0300 Subject: [PATCH] Tests: Fix multiprocess test by switching to asyncio.run --- tests/multiprocess_test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/multiprocess_test.py b/tests/multiprocess_test.py index 9c5189e..793b3b2 100644 --- a/tests/multiprocess_test.py +++ b/tests/multiprocess_test.py @@ -3,6 +3,7 @@ Publishing-Client -> PubSubServer -> Subscribing->Client """ + import os import sys import pytest @@ -10,7 +11,7 @@ import asyncio from multiprocessing import Process, Event as ProcEvent -from fastapi import APIRouter, FastAPI +from fastapi import FastAPI from fastapi_websocket_rpc.logger import get_logger @@ -35,11 +36,9 @@ def setup_server(): app = FastAPI() - router = APIRouter() # PubSub websocket endpoint endpoint = PubSubEndpoint() - endpoint.register_route(router, path="/pubsub") - app.include_router(router) + endpoint.register_route(app, path="/pubsub") uvicorn.run(app, port=PORT) @@ -51,6 +50,7 @@ def setup_publishing_client(): async def actual(): # Wait for other client to wake up before publishing to it CLIENT_START_SYNC.wait(5) + logger.info("Client start sync done") # Create a client and subscribe to topics client = PubSubClient() client.start_client(uri) @@ -62,7 +62,7 @@ async def actual(): assert published.result logger.info("Starting async publishing client") - asyncio.get_event_loop().run_until_complete(actual()) + asyncio.run(actual()) @pytest.fixture(scope="module")