Skip to content

Await connection in debugpy #1005

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

Open
ekeric13 opened this issue Feb 17, 2023 · 1 comment
Open

Await connection in debugpy #1005

ekeric13 opened this issue Feb 17, 2023 · 1 comment

Comments

@ekeric13
Copy link

  • asyncpg version: 0.27.0
  • PostgreSQL version: 15.1
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    :
  • Python version: 3.11
  • Platform: starlite
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: poetry
  • If you built asyncpg locally, which version of Cython did you use?: n/a
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : not sure

So I am using debugpy for debugging in vscode. Essentially this: python -m debugpy --listen 0.0.0.0:5678 ./myscript.py
I am using asyncpg + sqlalchemy. Specifically an AsyncSession

When I set a breakpoint and use the debug console I can normally await async functions.
But when I do this on an async query I get this error:

app_dev  | Traceback (most recent call last):
app_dev  |   File "/usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 755, in _start_transaction
app_dev  |     await self._transaction.start()
app_dev  |   File "/usr/local/lib/python3.11/site-packages/asyncpg/transaction.py", line 138, in start
app_dev  |     await self._connection.execute(query)
app_dev  |   File "/usr/local/lib/python3.11/site-packages/asyncpg/connection.py", line 317, in execute
app_dev  |     return await self._protocol.query(query, timeout)
app_dev  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app_dev  |   File "asyncpg/protocol/protocol.pyx", line 323, in query
app_dev  |   File "asyncpg/protocol/protocol.pyx", line 707, in asyncpg.protocol.protocol.BaseProtocol._check_state
app_dev  | asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress

Is there a way I can await async queries in the debug console?
Please let me know if this is a sqlAlchemy issue.

@gospodima
Copy link

gospodima commented Aug 29, 2024

I am getting the same error while running debug on fastapi + sqlalchemy project. Are there any updates on this issue?

My vscode debug config:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: FastAPI",
            "type": "debugpy",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "module": "uvicorn",
            "args": [
                "app.main:app",
                "--reload"
            ],
            "jinja": true,
            "justMyCode": false
        }
    ]
}

UPD: looks like the issue does not occur in case of replacing asyncpg with psycopg (3.2.1).

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

No branches or pull requests

2 participants