Skip to content

Commit 70fdaae

Browse files
committed
Tests: Fix multiprocess test by switching to asyncio.run
1 parent fac7d09 commit 70fdaae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/multiprocess_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
Publishing-Client -> PubSubServer -> Subscribing->Client
44
55
"""
6+
67
import os
78
import sys
89
import pytest
910
import uvicorn
1011
import asyncio
1112
from multiprocessing import Process, Event as ProcEvent
1213

13-
from fastapi import APIRouter, FastAPI
14+
from fastapi import FastAPI
1415

1516
from fastapi_websocket_rpc.logger import get_logger
1617

@@ -35,11 +36,9 @@
3536

3637
def setup_server():
3738
app = FastAPI()
38-
router = APIRouter()
3939
# PubSub websocket endpoint
4040
endpoint = PubSubEndpoint()
41-
endpoint.register_route(router, path="/pubsub")
42-
app.include_router(router)
41+
endpoint.register_route(app, path="/pubsub")
4342
uvicorn.run(app, port=PORT)
4443

4544

@@ -51,6 +50,7 @@ def setup_publishing_client():
5150
async def actual():
5251
# Wait for other client to wake up before publishing to it
5352
CLIENT_START_SYNC.wait(5)
53+
logger.info("Client start sync done")
5454
# Create a client and subscribe to topics
5555
client = PubSubClient()
5656
client.start_client(uri)
@@ -62,7 +62,7 @@ async def actual():
6262
assert published.result
6363

6464
logger.info("Starting async publishing client")
65-
asyncio.get_event_loop().run_until_complete(actual())
65+
asyncio.run(actual())
6666

6767

6868
@pytest.fixture(scope="module")

0 commit comments

Comments
 (0)