Skip to content

Commit 4f1aed8

Browse files
committed
make discover async
1 parent 3afabab commit 4f1aed8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,18 +615,22 @@ async def async_ensure_all_connected(client: AsyncMongoClient) -> None:
615615
connected_host_list = {hello["me"]}
616616

617617
# Run hello until we have connected to each host at least once.
618-
def discover():
618+
async def discover():
619619
i = 0
620620
while i < 100 and connected_host_list != target_host_list:
621-
hello: dict = client.admin.command(
621+
hello: dict = await client.admin.command(
622622
HelloCompat.LEGACY_CMD, read_preference=ReadPreference.SECONDARY
623623
)
624624
connected_host_list.update([hello["me"]])
625625
i += 1
626626
return connected_host_list
627627

628628
try:
629-
await async_wait_until(lambda: target_host_list == discover(), "connected to all hosts")
629+
630+
async def predicate():
631+
return target_host_list == await discover()
632+
633+
await async_wait_until(predicate, "connected to all hosts")
630634
except AssertionError as exc:
631635
raise AssertionError(
632636
f"{exc}, {connected_host_list} != {target_host_list}, {client.topology_description}"

0 commit comments

Comments
 (0)