Skip to content

Commit a6db6ea

Browse files
committed
Change httpx to requests
1 parent 20c8bdf commit a6db6ea

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies = [
3838
"platformdirs",
3939
"numexpr; platform_machine != 'wasm32'",
4040
"py-cpuinfo; platform_machine != 'wasm32'",
41-
"httpx; platform_machine != 'wasm32'",
41+
"requests",
4242
]
4343
version = "3.1.2.dev0"
4444

src/blosc2/c2array.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
from collections.abc import Sequence
1717

1818
import numpy as np
19+
import requests
1920

2021
import blosc2
2122

22-
if not blosc2.IS_WASM:
23-
import httpx
24-
2523
_subscriber_data = {
2624
"urlbase": os.environ.get("BLOSC_C2URLBASE"),
2725
"auth_token": "",
@@ -110,15 +108,15 @@ def _xget(url, params=None, headers=None, auth_token=None, timeout=TIMEOUT):
110108
if auth_token:
111109
headers = headers.copy() if headers else {}
112110
headers["Cookie"] = auth_token
113-
response = httpx.get(url, params=params, headers=headers, timeout=timeout)
111+
response = requests.get(url, params=params, headers=headers, timeout=timeout)
114112
response.raise_for_status()
115113
return response
116114

117115

118116
def _xpost(url, json=None, auth_token=None, timeout=TIMEOUT):
119117
auth_token = auth_token or _subscriber_data["auth_token"]
120118
headers = {"Cookie": auth_token} if auth_token else None
121-
response = httpx.post(url, json=json, headers=headers, timeout=timeout)
119+
response = requests.post(url, json=json, headers=headers, timeout=timeout)
122120
response.raise_for_status()
123121
return response.json()
124122

@@ -133,7 +131,7 @@ def _sub_url(urlbase, path):
133131
def login(username, password, urlbase):
134132
url = _sub_url(urlbase, "auth/jwt/login")
135133
creds = {"username": username, "password": password}
136-
resp = httpx.post(url, data=creds, timeout=TIMEOUT)
134+
resp = requests.post(url, data=creds, timeout=TIMEOUT)
137135
resp.raise_for_status()
138136
return "=".join(list(resp.cookies.items())[0])
139137

@@ -229,14 +227,14 @@ def __init__(self, path: str, /, urlbase: str | None = None, auth_token: str | N
229227
# Try to 'open' the remote path
230228
try:
231229
self.meta = info(self.path, self.urlbase, auth_token=self.auth_token)
232-
except httpx.HTTPStatusError:
230+
except requests.HTTPError:
233231
# Subscribe to root and try again. It is less latency to subscribe directly
234232
# than to check for the subscription.
235233
root, _ = self.path.split("/", 1)
236234
subscribe(root, self.urlbase, self.auth_token)
237235
try:
238236
self.meta = info(self.path, self.urlbase, auth_token=self.auth_token)
239-
except httpx.HTTPStatusError as err:
237+
except requests.HTTPError as err:
240238
raise FileNotFoundError(f"Remote path not found: {path}.\nError was: {err}") from err
241239
cparams = self.meta["schunk"]["cparams"]
242240
# Remove "filters, meta" from cparams; this is an artifact from the server

tests/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def c2sub_context():
3232
# def pytest_runtest_call(item):
3333
# try:
3434
# item.runtest()
35-
# except httpx.ConnectTimeout:
36-
# pytest.skip("Skipping test due to sporadic httpx.ConnectTimeout")
37-
# except httpx.ReadTimeout:
38-
# pytest.skip("Skipping test due to sporadic httpx.ReadTimeout")
39-
# except httpx.TimeoutException:
40-
# pytest.skip("Skipping test due to sporadic httpx.Timeout")
35+
# except requests.ConnectTimeout:
36+
# pytest.skip("Skipping test due to sporadic requests.ConnectTimeout")
37+
# except requests.ReadTimeout:
38+
# pytest.skip("Skipping test due to sporadic requests.ReadTimeout")
39+
# except requests.Timeout:
40+
# pytest.skip("Skipping test due to sporadic requests.Timeout")

tests/test_open_c2array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import pathlib
1010
import random
1111

12-
import httpx
1312
import numpy as np
1413
import pytest
14+
import requests
1515

1616
import blosc2
1717

@@ -69,7 +69,7 @@ def rand32():
6969
password = hex(rand32())
7070

7171
for _ in range(3):
72-
resp = httpx.post(
72+
resp = requests.post(
7373
f"{urlbase}auth/register", json={"email": username, "password": password}, timeout=15
7474
)
7575
if resp.status_code != 400:

0 commit comments

Comments
 (0)