Skip to content

Commit

Permalink
Fix ll.start_server() and add a test for full end-to-end server sta…
Browse files Browse the repository at this point in the history
…rtup (#984)
  • Loading branch information
dsmilkov authored Dec 19, 2023
1 parent 2bf7879 commit 8f8f486
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lilac/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,11 @@ def __init__(self, config: Config) -> None:
super().__init__(config)

def run() -> None:
loop = asyncio.get_event_loop()
loop.run_until_complete(self.serve())
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(self.serve())
except RuntimeError:
self.run()

self.thread = Thread(target=run)

Expand Down
9 changes: 8 additions & 1 deletion lilac/server_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test our public REST API."""
import os
from time import sleep

from fastapi.testclient import TestClient
from pytest_mock import MockerFixture
Expand All @@ -12,7 +13,7 @@
UserInfo,
get_session_user,
)
from .server import app
from .server import app, start_server, stop_server

client = TestClient(app)

Expand Down Expand Up @@ -161,3 +162,9 @@ def user() -> UserInfo:
),
auth_enabled=True,
)


def test_start_and_stop_server() -> None:
start_server()
sleep(1)
stop_server()

0 comments on commit 8f8f486

Please sign in to comment.