Skip to content

Commit

Permalink
fix(binaries): don't synchronously block in astream_to_file (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Nov 3, 2023
1 parent 8adf54e commit a63dc23
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/orb/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,9 +1758,10 @@ async def aiter_raw(self, chunk_size: Optional[int] = None) -> AsyncIterator[byt

@override
async def astream_to_file(self, file: str | os.PathLike[str]) -> None:
with open(file, mode="wb") as f:
path = anyio.Path(file)
async with await path.open(mode="wb") as f:
async for data in self.response.aiter_bytes():
f.write(data)
await f.write(data)

@override
async def aclose(self) -> None:
Expand Down

0 comments on commit a63dc23

Please sign in to comment.