Skip to content

feat: connection lifetime plugin - #1365

Open
karenc-bq wants to merge 4 commits into
mainfrom
feat/connectionLifeTime
Open

karenc-bq wants to merge 4 commits into
mainfrom
feat/connectionLifeTime

Conversation

@karenc-bq

Copy link
Copy Markdown
Contributor

Description

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

logger = Logger(__name__)


class AsyncConnectionLifetimePlugin(AsyncPlugin):

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.

Should we add more unit tests to cover basic functionality of this plugin?


@staticmethod
async def _close(connection: Any) -> None:
# aiomysql's close() is a coroutine, psycopg's async close() is too,

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.

Apparently its ensure_closed not close for a connection

# connection the pipeline opened and then discarded from being held
# alive by this map; a connection that cannot be weak-referenced is
# simply not pre-stamped and gets its timestamp on first use instead.
self._connection_creation_times: WeakKeyDictionary = WeakKeyDictionary()

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.

Don't we need to catch all the get and setter to catch when it cannot create a weak reference? Apparently not important since no supported driver hits this case.

@karenc-bq
karenc-bq force-pushed the feat/connectionLifeTime branch from b65dec2 to af5282c Compare November 18, 2026 11:57
@karenc-bq
karenc-bq force-pushed the feat/connectionLifeTime branch from af5282c to 24768d1 Compare November 21, 2026 00:17
@karenc-bq
karenc-bq force-pushed the feat/connectionLifeTime branch from 844aedc to b4ec4a1 Compare December 1, 2026 23:48

This branch has not been deployed

No deployments
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