Skip to content

Commit 4a596b5

Browse files
author
lkawka
committed
Remove port lock
Since Python is single-threaded and the fixtures turning-up servers aren't async, we don't need the lock.
1 parent 78a58cf commit 4a596b5

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

tests/e2e/push_notifications/test_default_push_notification_support.py

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import time
33
import uuid
44

5-
from multiprocessing import Lock
6-
75
import httpx
86
import pytest
97
import pytest_asyncio
@@ -34,29 +32,22 @@
3432
)
3533

3634

37-
@pytest.fixture(scope='session')
38-
def port_lock():
39-
"""Multiprocessing lock for acquiring available ephemeral ports."""
40-
return Lock()
41-
42-
4335
@pytest.fixture(scope='module')
44-
def notifications_server(port_lock):
36+
def notifications_server():
4537
"""
4638
Starts a simple push notifications injesting server and yields its URL.
4739
"""
48-
with port_lock:
49-
host = '127.0.0.1'
50-
port = find_free_port()
51-
url = f'http://{host}:{port}'
52-
53-
process = create_app_process(create_notifications_app(), host, port)
54-
process.start()
55-
try:
56-
wait_for_server_ready(f'{url}/health')
57-
except TimeoutError as e:
58-
process.terminate()
59-
raise e
40+
host = '127.0.0.1'
41+
port = find_free_port()
42+
url = f'http://{host}:{port}'
43+
44+
process = create_app_process(create_notifications_app(), host, port)
45+
process.start()
46+
try:
47+
wait_for_server_ready(f'{url}/health')
48+
except TimeoutError as e:
49+
process.terminate()
50+
raise e
6051

6152
yield url
6253

@@ -72,25 +63,21 @@ async def notifications_client():
7263

7364

7465
@pytest.fixture(scope='module')
75-
def agent_server(
76-
port_lock,
77-
notifications_client: httpx.AsyncClient,
78-
):
66+
def agent_server(notifications_client: httpx.AsyncClient):
7967
"""Starts a test agent server and yields its URL."""
80-
with port_lock:
81-
host = '127.0.0.1'
82-
port = find_free_port()
83-
url = f'http://{host}:{port}'
68+
host = '127.0.0.1'
69+
port = find_free_port()
70+
url = f'http://{host}:{port}'
8471

85-
process = create_app_process(
86-
create_agent_app(url, notifications_client), host, port
87-
)
88-
process.start()
89-
try:
90-
wait_for_server_ready(f'{url}/v1/card')
91-
except TimeoutError as e:
92-
process.terminate()
93-
raise e
72+
process = create_app_process(
73+
create_agent_app(url, notifications_client), host, port
74+
)
75+
process.start()
76+
try:
77+
wait_for_server_ready(f'{url}/v1/card')
78+
except TimeoutError as e:
79+
process.terminate()
80+
raise e
9481

9582
yield url
9683

0 commit comments

Comments
 (0)