Skip to content

Commit bf68107

Browse files
jqin61adrianqin
andauthored
Make connect_timeout configurable (#218)
* add timeout config * wrap into a constant * property format consistency * linting * update doc * make config sample more informative --------- Co-authored-by: adrianqin <adrianqin2019@gmail.com>
1 parent 584709f commit bf68107

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

mkdocs/docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ For the FileIO there are several configuration options available:
7474
| s3.signer | bearer | Configure the signature version of the FileIO. |
7575
| s3.region | us-west-2 | Sets the region of the bucket |
7676
| s3.proxy-uri | http://my.proxy.com:8080 | Configure the proxy server to be used by the FileIO. |
77+
| s3.connect-timeout | 60.0 | Configure socket connection timeout, in seconds. |
7778

7879
### HDFS
7980

pyiceberg/io/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
S3_SESSION_TOKEN = "s3.session-token"
5252
S3_REGION = "s3.region"
5353
S3_PROXY_URI = "s3.proxy-uri"
54+
S3_CONNECT_TIMEOUT = "s3.connect-timeout"
5455
HDFS_HOST = "hdfs.host"
5556
HDFS_PORT = "hdfs.port"
5657
HDFS_USER = "hdfs.user"

pyiceberg/io/fsspec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
GCS_TOKEN,
5050
GCS_VERSION_AWARE,
5151
S3_ACCESS_KEY_ID,
52+
S3_CONNECT_TIMEOUT,
5253
S3_ENDPOINT,
5354
S3_PROXY_URI,
5455
S3_REGION,
@@ -127,6 +128,9 @@ def _s3(properties: Properties) -> AbstractFileSystem:
127128
if proxy_uri := properties.get(S3_PROXY_URI):
128129
config_kwargs["proxies"] = {"http": proxy_uri, "https": proxy_uri}
129130

131+
if connect_timeout := properties.get(S3_CONNECT_TIMEOUT):
132+
config_kwargs["connect_timeout"] = connect_timeout
133+
130134
fs = S3FileSystem(client_kwargs=client_kwargs, config_kwargs=config_kwargs)
131135

132136
for event_name, event_function in register_events.items():

pyiceberg/io/pyarrow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
HDFS_PORT,
9393
HDFS_USER,
9494
S3_ACCESS_KEY_ID,
95+
S3_CONNECT_TIMEOUT,
9596
S3_ENDPOINT,
9697
S3_PROXY_URI,
9798
S3_REGION,
@@ -330,6 +331,9 @@ def _initialize_fs(self, scheme: str, netloc: Optional[str] = None) -> FileSyste
330331
if proxy_uri := self.properties.get(S3_PROXY_URI):
331332
client_kwargs["proxy_options"] = proxy_uri
332333

334+
if connect_timeout := self.properties.get(S3_CONNECT_TIMEOUT):
335+
client_kwargs["connect_timeout"] = connect_timeout
336+
333337
return S3FileSystem(**client_kwargs)
334338
elif scheme == "hdfs":
335339
from pyarrow.fs import HadoopFileSystem

0 commit comments

Comments
 (0)