Skip to content

Commit

Permalink
Test: hosting: handle writes during start_room (ArchipelagoMW#3492)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
black-sliver authored and James Schurig committed Jun 13, 2024
1 parent 4e8a82c commit e483598
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/hosting/webhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e483598

Please sign in to comment.