Skip to content

feat: connection lifetime plugin - #1365

Merged
karenc-bq merged 4 commits into
mainfrom
feat/connectionLifeTime
Dec 2, 2026
Merged

karenc-bq merged 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 2 times, most recently 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
@karenc-bq
karenc-bq force-pushed the feat/connectionLifeTime branch from b4ec4a1 to c5a96db Compare December 2, 2026 20:00
@karenc-bq
karenc-bq merged commit 86888e5 into main Dec 2, 2026
8 checks passed
@karenc-bq
karenc-bq deleted the feat/connectionLifeTime branch December 2, 2026 20:00
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