Skip to content

Commit

Permalink
Try fixing multiprocess test
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Apr 24, 2024
1 parent 4c83f56 commit 86c5ff2
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/multiprocess_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Publishing-Client -> PubSubServer -> Subscribing->Client
"""

import os
import sys
import pytest
Expand Down Expand Up @@ -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 @@ -52,14 +51,14 @@ async def actual():
# Wait for other client to wake up before publishing to it
CLIENT_START_SYNC.wait(5)
# Create a client and subscribe to topics
client = PubSubClient()
client.start_client(uri)
# wait for the client to be ready
await client.wait_until_ready()
# publish event
logger.info("Publishing event")
published = await client.publish([EVENT_TOPIC], data=DATA)
assert published.result
async with PubSubClient() as client:
client.start_client(uri)
# wait for the client to be ready
await client.wait_until_ready()
# publish event
logger.info("Publishing event")
published = await client.publish([EVENT_TOPIC], data=DATA)
assert published.result

logger.info("Starting async publishing client")
asyncio.get_event_loop().run_until_complete(actual())
Expand Down

0 comments on commit 86c5ff2

Please sign in to comment.