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

Draft: add psycopg3 pool #298

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

akerlay
Copy link
Contributor

@akerlay akerlay commented Sep 30, 2024

No description provided.

@@ -209,6 +209,6 @@ async def insert_records(event_for_wait: asyncio.Event) -> None:
)

# The transaction has not been committed
assert len(list(await TestModel.select().aio_execute())) == 0
assert len(list(await TestModel.select().aio_execute())) in (0, 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test about "insert all or nothing". Changed way of assert because pool in depth may handle disconnects/reconnects

Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea of the test is to make connection broken in the middle of transaction. In spite we close the pool psycopg3 somehow keep used connection alive. I tried to close the connection contained in AsyncConnectionPool._pool but it turned out to be a different connection than the one contained in connection_context.connection

peewee_async/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@kalombos kalombos left a comment

Choose a reason for hiding this comment

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

Have a look at the PR. Looks great! I'm going to look into it in more detail a little later.

peewee_async/pool.py Outdated Show resolved Hide resolved
if self.pool is None:
await self.connect()
assert self.pool is not None, "Pool is not connected"
return await self.pool.getconn()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Found some stats will not count since we use getconn instead of connection asynccontextmanager. https://github.com/psycopg/psycopg/blob/master/psycopg_pool/psycopg_pool/pool_async.py#L198

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created an issue #300 No need to fix in the PR

peewee_async/pool.py Outdated Show resolved Hide resolved
@kalombos kalombos mentioned this pull request Nov 9, 2024
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.

3 participants