Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use asynccontextmanager for FastAPI lifespan #2597

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/unit_tests/test_axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# DEALINGS IN THE SOFTWARE.


import asyncio
import contextlib
import re
import threading
import time
Expand Down Expand Up @@ -795,6 +797,7 @@ async def test_threaded_fastapi():
server_started = threading.Event()
server_stopped = threading.Event()

@contextlib.asynccontextmanager
async def lifespan(app):
server_started.set()
yield
Expand All @@ -814,6 +817,9 @@ async def lifespan(app):

server_started.wait()

while not (server.started or server_stopped.is_set()):
await asyncio.sleep(1)
zyzniewski-reef marked this conversation as resolved.
Show resolved Hide resolved

assert server.is_running is True

async with aiohttp.ClientSession(
Expand Down
Loading