Skip to content

Fix no-pooling session isolation#118

Merged
hownowstephen merged 2 commits into
mainfrom
fix-pr94-session-isolation
May 6, 2026
Merged

Fix no-pooling session isolation#118
hownowstephen merged 2 commits into
mainfrom
fix-pr94-session-isolation

Conversation

@hownowstephen

@hownowstephen hownowstephen commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • create a fresh requests Session per request when use_connection_pooling=False
  • keep pooled clients using the shared cached session
  • add ClientBase regression tests for pooled reuse and overlapping no-pooling requests

Context

Applies the concept from #94 to current main. #109 avoided a None.close() traceback, but disabled pooling could still share self._current_session across concurrent requests.

Tests

  • .venv312/bin/python -m unittest tests.test_client_base -v
  • .venv312/bin/python -m ruff check customerio/client_base.py tests/test_client_base.py
  • .venv312/bin/python -m ruff format --check customerio/client_base.py tests/test_client_base.py
  • make test PYTHON=.venv312/bin/python

Note

Medium Risk
Changes HTTP session lifecycle and request dispatching, which can affect performance and retry/connection behavior under load. Adds coverage for concurrent no-pooling requests to reduce regression risk.

Overview
Fixes ClientBase so use_connection_pooling=False creates and closes a fresh requests.Session per request (via a context manager) instead of sharing self._current_session across calls.

Simplifies session management by removing _get_session/_close and related logging, and adds regression tests verifying pooled session reuse and isolation/cleanup for overlapping no-pooling requests.

Reviewed by Cursor Bugbot for commit d5edf59. Bugbot is set up for automated code reviews on this repo. Configure here.

@joeybaer

joeybaer commented May 6, 2026

Copy link
Copy Markdown

@cusror review

@hownowstephen
hownowstephen merged commit 1140897 into main May 6, 2026
10 checks passed
@hownowstephen
hownowstephen deleted the fix-pr94-session-isolation branch June 11, 2026 04:38
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