MagicStack / MagicStack/asyncpg

Cursor cannot be used with externally-managed transaction

Open
#1,311 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

Asyncpg 0.31.0, installed from pip and running against a local pg database. This is not a deployment issue, but rather an issue w/the check performed by `Cursor._check_ready()`.

https://github.com/MagicStack/asyncpg/blob/db8ecc2a38e16fb0c090aef6f5506547c2831c24/asyncpg/cursor.py#L114-L116

Working on implementing streaming results for Peewee and I'm running into an issue w/the Cursor `_check_ready()`. Currently it requires an asyncpg-managed transaction in order to proceed. Is there a reason it doesn't do a similar check to the one here, where it queries `is_in_transaction()`?

https://github.com/MagicStack/asyncpg/blob/db8ecc2a38e16fb0c090aef6f5506547c2831c24/asyncpg/connection.py#L1532

I'd like to be able to use server-side cursors with Peewee's library-managed transactions.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with asyncpg/cursor.py at Cursor._check_ready(), then compare its transaction check with connection.py at is_in_transaction(). Determine whether readiness can recognize an externally managed transaction without breaking asyncpg-managed cursors; done means server-side cursors work with Peewee's library-managed transactions.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.