Skip to content

Commit

Permalink
test: Replace Thread with Process for proper cleanup(?)
Browse files Browse the repository at this point in the history
  • Loading branch information
airblast-dev committed Jun 5, 2024
1 parent 0b0f451 commit d387695
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from threading import Thread
from multiprocessing import Process

import pytest

Expand All @@ -7,18 +7,16 @@
from .requests.vs_api import app


# FIX: This almost always works, however a proper way to assure the server has started should be implemented.
# TODO: This always works, however a proper way to assure the server has started should be implemented.
@pytest.fixture(scope="session", autouse=True)
def test_server():
thread = Thread(
target=app.run,
daemon=True,
kwargs={
"host": "localhost",
"port": 5000,
},
)
thread.start()
proc = Process(target=app.run, kwargs={"host": "localhost", "port": 5000})
proc.start()
yield
proc.kill()
proc.join()


@pytest.fixture
def anyio_backend():
return "asyncio"
Expand Down

0 comments on commit d387695

Please sign in to comment.