Skip to content

Re-use single session instead of opening many connections#390

Open
hugovk wants to merge 1 commit into
python:mainfrom
hugovk:add_to_pydotorg-session
Open

Re-use single session instead of opening many connections#390
hugovk wants to merge 1 commit into
python:mainfrom
hugovk:add_to_pydotorg-session

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented May 15, 2026

Saves re-opening a connection a dozen or so times.

Copy link
Copy Markdown
Member

@savannahostrowski savannahostrowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits, just because you formatted one URL to an f-string. 🙂

Comment thread add_to_pydotorg.py
@@ -297,7 +300,7 @@ def query_object(base_url: str, objtype: str, **params: Any) -> int:
"""Find an API object by query parameters."""
uri = base_url + f"downloads/{objtype}/"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uri = base_url + f"downloads/{objtype}/"
uri = f"{base_url}downloads/{objtype}/"

Comment thread add_to_pydotorg.py
Comment on lines +312 to 315
resp = session.post(
base_url + "downloads/" + objtype + "/",
data=json.dumps(datadict),
headers=headers,
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resp = session.post(
base_url + "downloads/" + objtype + "/",
data=json.dumps(datadict),
headers=headers,
)
resp = session.post(f"{base_url}downloads/{objtype}/", data=json.dumps(datadict))

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

Successfully merging this pull request may close these issues.

2 participants