MagicStack / MagicStack/asyncpg

Await connection in debugpy

Đang mở
#1,005 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
8.1k
Fork
468
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

* **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](https://github.com/magicstack/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](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#preventing-implicit-io-when-using-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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lệnh debugpy với Python 3.11, asyncpg 0.27.0, PostgreSQL 15.1 và SQLAlchemy AsyncSession, sau đó kiểm tra lỗi thao tác đồng thời bắt nguồn từ đâu. Xác định xem hành vi này thuộc về asyncpg, SQLAlchemy hay debugpy; công việc chỉ được coi là hoàn tất khi đã xác nhận bản sửa lỗi hoặc có một giải pháp được ghi chép rõ ràng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
postgresql, python, sqlalchemy, vscode
Lĩnh vực
databases, devtools
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.