From bd72e5c3ba4e62383ab009878b486b5ea8517186 Mon Sep 17 00:00:00 2001 From: Daniel Smilkov Date: Tue, 23 Jan 2024 15:48:42 -0500 Subject: [PATCH] Fix a non blocking start_server (#1117) This fixes the `RuntimeError: cannot schedule new futures after interpreter shutdown` --- lilac/server.py | 2 +- lilac/server_test.py | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lilac/server.py b/lilac/server.py index 3cb7a8a70..2a6374da4 100644 --- a/lilac/server.py +++ b/lilac/server.py @@ -261,7 +261,7 @@ def open_browser() -> None: block = False try: - asyncio.get_event_loop() + asyncio.get_running_loop() except RuntimeError: block = True diff --git a/lilac/server_test.py b/lilac/server_test.py index 49a5419e4..0f94fa730 100644 --- a/lilac/server_test.py +++ b/lilac/server_test.py @@ -1,6 +1,5 @@ """Test our public REST API.""" import os -from time import sleep from fastapi.testclient import TestClient from pytest_mock import MockerFixture @@ -13,7 +12,7 @@ UserInfo, get_session_user, ) -from .server import app, start_server, stop_server +from .server import app client = TestClient(app) @@ -175,9 +174,3 @@ def user() -> UserInfo: ), auth_enabled=True, ) - - -def test_start_and_stop_server() -> None: - start_server() - sleep(1) - stop_server()