From e483598d30e7db2a29172825b57c40c70827a9a8 Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:51:09 +0200 Subject: [PATCH] Test: hosting: handle writes during start_room (#3492) Note: maybe we'd also want to add such handling to WebHost itself, but this is out of scope for getting hosting test to work. --- test/hosting/webhost.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/hosting/webhost.py b/test/hosting/webhost.py index e1e31ae466c4..4db605e8c1ea 100644 --- a/test/hosting/webhost.py +++ b/test/hosting/webhost.py @@ -66,12 +66,19 @@ def create_room(app_client: "FlaskClient", seed: str, auto_start: bool = False) def start_room(app_client: "FlaskClient", room_id: str, timeout: float = 30) -> str: from time import sleep + import pony.orm + poll_interval = .2 print(f"Starting room {room_id}") no_timeout = timeout <= 0 while no_timeout or timeout > 0: - response = app_client.get(f"/room/{room_id}") + try: + response = app_client.get(f"/room/{room_id}") + except pony.orm.core.OptimisticCheckError: + # hoster wrote to room during our transaction + continue + assert response.status_code == 200, f"Starting room for {room_id} failed: status {response.status_code}" match = re.search(r"/connect ([\w:.\-]+)", response.text) if match: