|
1 | 1 | from typing import AsyncIterator, IO, List, Literal, Optional, Union, cast, overload |
2 | 2 | from http import HTTPStatus |
3 | 3 |
|
| 4 | +import httpx |
| 5 | + |
4 | 6 | from typing_extensions import Unpack |
5 | 7 |
|
6 | 8 | from e2b.api import handle_api_exception |
|
33 | 35 | ) |
34 | 36 | from e2b.volume.client.types import File as FilePayload, UNSET |
35 | 37 | from e2b.volume.client_async import get_api_client as get_volume_api_client |
36 | | -from e2b.volume.connection_config import VolumeApiParams, VolumeConnectionConfig |
| 38 | +from e2b.volume.connection_config import ( |
| 39 | + VolumeApiParams, |
| 40 | + VolumeConnectionConfig, |
| 41 | + FILE_TIMEOUT, |
| 42 | +) |
37 | 43 | from e2b.volume.types import ( |
38 | 44 | VolumeAndToken, |
39 | 45 | VolumeInfo, |
@@ -457,7 +463,9 @@ async def read_file( |
457 | 463 | api_client = get_volume_api_client(config) |
458 | 464 |
|
459 | 465 | params = {"path": path} |
460 | | - timeout = config.get_request_timeout(opts.get("request_timeout")) |
| 466 | + timeout = VolumeConnectionConfig._get_request_timeout( |
| 467 | + FILE_TIMEOUT, opts.get("request_timeout") |
| 468 | + ) |
461 | 469 |
|
462 | 470 | if format == "stream": |
463 | 471 |
|
@@ -536,7 +544,12 @@ async def write_file( |
536 | 544 | :return: Information about the written file |
537 | 545 | """ |
538 | 546 | config = self._get_volume_config(**opts) |
| 547 | + upload_timeout = VolumeConnectionConfig._get_request_timeout( |
| 548 | + FILE_TIMEOUT, opts.get("request_timeout") |
| 549 | + ) |
539 | 550 | api_client = get_volume_api_client(config) |
| 551 | + if upload_timeout is not None: |
| 552 | + api_client = api_client.with_timeout(httpx.Timeout(upload_timeout)) |
540 | 553 |
|
541 | 554 | if isinstance(data, str): |
542 | 555 | data_bytes = data.encode("utf-8") |
|
0 commit comments