Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from requests to httpx #33

Open
dmyersturnbull opened this issue Aug 28, 2024 · 0 comments
Open

Switch from requests to httpx #33

dmyersturnbull opened this issue Aug 28, 2024 · 0 comments

Comments

@dmyersturnbull
Copy link
Contributor

requests is limited to HTTP/1.1. With httpx, you can build a client with httpx.Client(http1=False, http2=True), so that HTTP/2 is always used.

HTTP/3 support would be nice (it can be dramatically faster). RCSB doesn't support it yet, and we would need a separate package (aioquic), which is HTTP/3-only.

This line:

part_response = requests.post(headers={"Content-Type": "application/graphql"}, data=query, url=PDB_URL, timeout=10).json()

Can be:

with httpx.Client(http1=False, http2=True) as client:
    response = client.post(headers="Content-Type": "application/graphql"}, data=query, url=self.endpoint, timeout=self.timeout_sec)
    response.raise_for_status()
    data = response.json()
I'm also proposing replacing `PDB_URL` with an attribute `self.endpoint` and `10` with `self.timeout_sec`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant