Skip to content

Commit

Permalink
tests: introduce ConnectionTimeoutWarning to reduce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 8, 2024
1 parent 04dc7bf commit 2e406e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
used by any other piece of software and because combining file-like
objects external links are quirky and their combination finally broke with h5py 3.12
- enh: added integrity check for external links
- tests: reduce warnings
0.61.5
- fix: integrity check failed for empty datasets
0.61.4
Expand Down
7 changes: 6 additions & 1 deletion dclab/http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ETagNotInResponseHeaderWarning(UserWarning):
"""Used for cases where the requests.Response does not contain an ETag"""


class ConnectionTimeoutWarning(UserWarning):
"""Used when a connection fails or times out"""


class HTTPFile(io.IOBase):
def __init__(self, url, chunk_size=2**18, keep_chunks=200):
"""Chunk-cached access to a URL supporting range requests
Expand Down Expand Up @@ -243,7 +247,8 @@ def get(self, *args, **kwargs):
requests.exceptions.ConnectTimeout,
requests.urllib3.exceptions.ConnectionError,
requests.urllib3.exceptions.ReadTimeoutError) as e:
warnings.warn(f"Encountered {e} for {args} {kwargs}")
warnings.warn(f"Encountered {e} for {args} {kwargs}",
ConnectionTimeoutWarning)
continue
else:
break
Expand Down
2 changes: 2 additions & 0 deletions tests/test_rtdc_fmt_dcor_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def test_basin_as_dict(tmp_path):
"https://example.com/nonexistentbucket/nonexistentkey",
f"https://objectstore.hpccloud.mpcdf.mpg.de/noexist-{uuid.uuid4()}/key",
])
@pytest.mark.filterwarnings(
"ignore::dclab.http_utils.ConnectionTimeoutWarning")
def test_basin_not_available(url):
h5path = retrieve_data("fmt-hdf5_fl_wide-channel_2023.zip")

Expand Down

0 comments on commit 2e406e4

Please sign in to comment.