Skip to content

Commit eddac53

Browse files
committed
Achieve parity in async/sync impls
1 parent ec476ba commit eddac53

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

weaviate/collections/batch/async_.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def __init__(self, recv: asyncio.Task[None], loop: asyncio.Task[None]) -> None:
6060
def all_alive(self) -> bool:
6161
return all([not self.recv.done(), not self.loop.done()])
6262

63-
async def gather(self) -> None:
63+
async def gather(self, timeout: float | None = None) -> None:
6464
tasks = [self.recv, self.loop]
65-
await asyncio.gather(*tasks, return_exceptions=True)
65+
await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), timeout=timeout)
6666

6767

6868
class _BatchBaseAsync:
@@ -186,7 +186,7 @@ async def _wait(self) -> None:
186186
# this is how long an insert will take to timeout for, so we wait at most this time +5s for the batch to finish after shutdown is initiated, in case the server never hangs up
187187
shutdown_timeout = self.__connection.timeout_config.insert + 5
188188
try:
189-
await asyncio.wait_for(self.__bg_tasks.gather(), timeout=shutdown_timeout)
189+
await self.__bg_tasks.gather(timeout=shutdown_timeout)
190190
except asyncio.TimeoutError as e:
191191
raise WeaviateBatchStreamError(
192192
"Background batch tasks did not terminate after forced shutdown."

0 commit comments

Comments
 (0)