Test failure in test_pool_handles_transaction_exit_in_asyncgen_2 with Python 3.15.0a5, PYTHONASYNCIODEBUG=1

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

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
postgresql, python

Research direction

Reproduce the failure with Python 3.15.0a5, PYTHONASYNCIODEBUG=1, and the documented pytest command. Start with TestPool.test_pool_handles_transaction_exit_in_asyncgen_2 and asyncpg/_testbase/init.py:92, then compare the run without asyncio debug and check the separate standby timeout; done means the reported test failures are understood and resolved or clearly isolated.

Written by the indexing model from the issue text.

Description

$ git clone https://github.com/MagicStack/asyncpg.git
$ cd asyncpg
$ git submodule update --init --recursive
$ uv venv --python 3.15
Using CPython 3.15.0a5 interpreter at: /usr/bin/python3.15
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
$ uv pip install -e .[gssauth]
$ uv pip install --group test
$ PYTHONASYNCIODEBUG=1 pytest -v
[…]
________________________________________________________________ TestPool.test_pool_handles_transaction_exit_in_asyncgen_2 _________________________________________________________________
Traceback (most recent call last):
  File "/usr/lib64/python3.15/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib64/python3.15/unittest/case.py", line 667, in run
    self._callTestMethod(testMethod)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib64/python3.15/unittest/case.py", line 613, in _callTestMethod
    result = method()
  File "/home/ben/src/forks/asyncpg/asyncpg/_testbase/__init__.py", line 92, in wrapper
    self.loop.run_until_complete(coro)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib64/python3.15/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
RuntimeError: cannot reuse already awaited coroutine

The above instructions also result in TestConnectionAttributes.test_prefer_standby_picks_master_when_standby_is_down failing due to a timeout, but I’m not seeing that when I build https://src.fedoraproject.org/rpms/python-asyncpg.

The test TestPool.test_pool_handles_transaction_exit_in_asyncgen_2 passes when PYTHONASYNCIODEBUG=1 is not set.

Dominant language
Python
Stars
8.1k
Forks
469
Avg merge
2d 20h
Merged PRs (30d)
9

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.

More from MagicStack/asyncpg

All issues in MagicStack/asyncpg

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.