Skip to content

fix: move PoolKey to utils/pool_key so the async provider can share it - #1272

Merged
karenc-bq merged 2 commits into
mainfrom
fix/async-sqlalchemy-import
Aug 24, 2026
Merged

fix: move PoolKey to utils/pool_key so the async provider can share it#1272
karenc-bq merged 2 commits into
mainfrom
fix/async-sqlalchemy-import

Conversation

@karenc-bq

@karenc-bq karenc-bq commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Description

Moves PoolKey out of sql_alchemy_connection_provider.py into a new dependency-free module, aws_advanced_python_wrapper/utils/pool_key.py.

AsyncPooledConnectionProvider keys its internal pools with the same PoolKey as the sync provider, but it previously had to reach into sql_alchemy_connection_provider to get it. That module imports sqlalchemy at module scope, and SQLAlchemy is a dev-only dependency of this package — so importing the async pooled connection provider pulled in SQLAlchemy and would raise ModuleNotFoundError for anyone using the async internal connection pool without SQLAlchemy installed. The async pooled provider itself has no use for SQLAlchemy; it manages its own async pools.

PoolKey is a two-field cache key (url, extra_key) with no pool-implementation dependencies, so the new module imports nothing beyond typing. Both providers now import it from the canonical location, and the class itself is unchanged — this is a pure move plus import updates, with no behavior change.

The relocation also drops the re-export shims that briefly stood in for the old import paths. PoolKey is an internal cache key: it is not exported from aws_advanced_python_wrapper/__init__.py, is not referenced anywhere in docs/, and is not part of the documented public API, so aliases in the two provider modules only advertise a second and third place the class appears to live. Note that from aws_advanced_python_wrapper.sql_alchemy_connection_provider import PoolKey still resolves regardless, since that module imports the name for its own use — anyone who reached for the old path keeps working without a documented alias.

Changes

  • Add aws_advanced_python_wrapper/utils/pool_key.py holding PoolKey, with a module docstring explaining why it stands alone.
  • sql_alchemy_connection_provider.py: import PoolKey from the new module; drop the class definition and the trailing __all__ block (the sync modules in this package do not otherwise declare __all__).
  • aio/pooled_connection_provider.py: import PoolKey from the new module instead of from the SQLAlchemy provider, and drop it from __all__.
  • Tests: test_pool_key.py, test_sql_alchemy_pooled_connection_provider.py, and test_aio_pooled_connection_provider.py import PoolKey from the canonical path.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sophia-bq sophia-bq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Otherwise the change looks good!

Comment thread aws_advanced_python_wrapper/aio/pooled_connection_provider.py
@karenc-bq
karenc-bq merged commit b2b6b1b into main Aug 24, 2026
9 checks passed
@karenc-bq
karenc-bq deleted the fix/async-sqlalchemy-import branch August 24, 2026 17:36
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