Skip to content

Fix asyncpg rollback example #18015

Open
Open
@dikshant

Description

@dikshant

Dikshant Adhikari (dikshant) commented:

https://github.com/cockroachdb/example-app-python-asyncpg/blob/main/example.py#L86

uses conn.rollback() which is not a thing. We are doing async with conn.transaction(): we should do async with conn.transaction() as t: and then t.rollback() instead of conn.rollback() because rollbacks are defined at the transaction level and not the connection level
https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.transaction.Transaction

time.sleep should also be updated to use await async.io sleep as a best practie
https://github.com/cockroachdb/example-app-python-asyncpg/blob/main/example.py#L90

Jira Issue: DOC-9106

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions