Skip to content

Commit

Permalink
Tests: Fix multiprocess test by switching to asyncio.run
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Apr 24, 2024
1 parent fac7d09 commit 70fdaae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/multiprocess_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
Publishing-Client -> PubSubServer -> Subscribing->Client
"""

import os
import sys
import pytest
import uvicorn
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

Expand All @@ -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)


Expand All @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit 70fdaae

Please sign in to comment.