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

notify api clients: use a common thread-local requests.Session #5394

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

risicle
Copy link
Member

@risicle risicle commented Mar 2, 2025

Depends on alphagov/notifications-python-client#255

We're currently dividing the effectiveness of any connection-pooling we're doing to api-web by >20x by having a separate connection pool per sub-api-client. This contributes to the excessive number of GreenThreads api-web needs to keep active when it has keepalive enabled.

Instead keep a single (lazily-constructed) requests.Session per-thread which gets injected into each sub-api-client at lazy-construction-time.

risicle added 2 commits March 2, 2025 13:49
this allows us to share the same connection pool between
the >20 api client instances we have, providing better
utilization
Copy link
Contributor

@CrystalPea CrystalPea left a comment

Choose a reason for hiding this comment

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

Looks good in general, just not sure about the temp dependency bump.

EDIT: just saw this is a draft PR, so I guess this will be fixed before it's ready to merge?

@@ -13,7 +13,7 @@ pyexcel-io==0.6.6
pyexcel-xls==0.7.0
pyexcel-xlsx==0.6.0
pyexcel-ods3==0.6.1
notifications-python-client==10.0.0
notifications-python-client @ git+https://github.com/alphagov/notifications-python-client.git@5eafd129144f5006e2d7bf501a9c38450979d4b6
Copy link
Contributor

Choose a reason for hiding this comment

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

so I can see this is a TEMP bump - what plan do we have to ensure this temp doesn't become a semi-permanent thing that will throw someone later?

Also is there a PR for these python client changes that needs reviewing?

Copy link
Member Author

Choose a reason for hiding this comment

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

☝️ linked in the PR description

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