Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pytest_databases/_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,18 @@ def run(
ulimits=ulimits,
mem_limit=mem_limit,
)
container.reload()

# reload the container; sometimes it can take a while before docker
# spins it up and the metadata becomes available, so we're redoing the
# check with a small incremental backup here
for i in range(10):
if any(v for v in container.ports.values()):
break
container.reload()
time.sleep(0.1 + (i / 10))
else:
msg = f"Service {name!r} failed to create container"
raise ValueError(msg)

host_port = int(
container.ports[next(k for k in container.ports if k.startswith(str(container_port)))][0]["HostPort"]
Expand Down
Loading