Skip to content

Commit 3fc96c0

Browse files
committed
Use a timeout instead of attempt count
1 parent ec6262f commit 3fc96c0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/integration/dataframe/test_dataframe.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _wait_for_table_data(
114114
table_id: str,
115115
minimum_row_count: int,
116116
index_column: str = "index",
117-
max_attempts: int = 10,
117+
timeout: float = 5.0,
118118
sleep_duration: float = 0.2,
119119
) -> int:
120120
"""Helper function to wait for table data to be available by polling get_table_data.
@@ -124,24 +124,27 @@ def _wait_for_table_data(
124124
table_id: ID of the table to check
125125
expected_row_count: Expected number of rows in the table
126126
index_column: Name of the index column to query (default: "index")
127-
max_attempts: Maximum number of retry attempts (default: 10)
127+
timeout: Maximum time to wait in seconds (default: 2.0)
128128
sleep_duration: Sleep duration between attempts in seconds (default: 0.2)
129129
130130
Returns:
131131
The actual number of rows found in the table
132132
"""
133-
for attempt in range(max_attempts):
134-
if attempt > 0:
135-
time.sleep(sleep_duration)
133+
start_time = time.time()
134+
135+
while True:
136136
response = client.get_table_data(table_id, columns=[index_column], take=1)
137137
actual_row_count = response.total_row_count
138138
if actual_row_count >= minimum_row_count:
139139
return actual_row_count
140140

141-
assert False, (
142-
f"Failed to get expected row count {minimum_row_count} after "
143-
f"{max_attempts} attempts (last count: {actual_row_count})"
144-
)
141+
elapsed_time = time.time() - start_time
142+
assert elapsed_time < timeout, (
143+
f"Failed to get expected row count {minimum_row_count} after "
144+
f"{elapsed_time:.2f} seconds (last count: {actual_row_count})"
145+
)
146+
147+
time.sleep(sleep_duration)
145148

146149
def _new_single_int_table(self, create_table, column_name: str = "a") -> str:
147150
return create_table(

0 commit comments

Comments
 (0)