MagicStack / MagicStack/asyncpg

copy_from_query fails without uvloop

Đang mở
#529 2 bình luận 9 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.20.1
  • PostgreSQL version: PostgreSQL 11.5, compiled by Visual C++ build 1800, 64-bit
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : Azure
  • Python version: 3.8.1
  • Platform: Windows
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : On Linux system work with uvloop but not without uvloop.

Trying to use copy_from_query to make a csv from a view, with 27 000 rows. But it fails on windows or on Linux without uvloop. If I limit the number of rows to 100 it works.

Note: It works fine on Linux with uvloop, but not without uvloop.

Error message on windows:
Traceback (most recent call last): File "C:\Program Files\Python38\lib\runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python38\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\kf9762\Desktop\spot\project\app\__main__.py", line 46, in <module> asyncio.run(query()) File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run return loop.run_until_complete(main) File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 612, in run_until_complete return future.result() File "C:\Users\kf9762\Desktop\spot\project\app\__main__.py", line 40, in query await con.copy_from_query("SELECT * FROM spot.csv_utc", format='csv', header=True, output="spot.csv") File "C:\Users\kf9762\Desktop\spot\project\.venv\lib\site-packages\asyncpg\connection.py", line 591, in copy_from_query return await self._copy_out(copy_stmt, output, timeout) File "C:\Users\kf9762\Desktop\spot\project\.venv\lib\site-packages\asyncpg\connection.py", line 796, in _copy_out return await self._protocol.copy_out(copy_stmt, writer, timeout) File "asyncpg\protocol\protocol.pyx", line 341, in copy_out File "asyncpg\protocol\protocol.pyx", line 342, in asyncpg.protocol.protocol.BaseProtocol.copy_out File "asyncpg\protocol\coreproto.pyx", line 92, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages File "asyncpg\protocol\coreproto.pyx", line 359, in asyncpg.protocol.protocol.CoreProtocol._process__copy_out_data File "asyncpg\protocol\coreproto.pyx", line 428, in asyncpg.protocol.protocol.CoreProtocol._parse_copy_data_msgs File "asyncpg\protocol\protocol.pyx", line 847, in asyncpg.protocol.protocol.BaseProtocol._on_result File "asyncpg\protocol\protocol.pyx", line 769, in asyncpg.protocol.protocol.BaseProtocol._dispatch_result AttributeError: 'NoneType' object has no attribute 'cancelled' Fatal error on SSL transport protocol: <asyncio.sslproto.SSLProtocol object at 0x00000279CB926A90> transport: <_ProactorSocketTransport fd=612 read=<_OverlappedFuture cancelled>> Traceback (most recent call last): File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 685, in _process_write_backlog self._transport.write(chunk) File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 359, in write self._loop_writing(data=bytes(data)) File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 395, in _loop_writing self._write_fut = self._loop._proactor.send(self._sock, data) AttributeError: 'NoneType' object has no attribute 'send' Exception ignored in: <function _SSLProtocolTransport.__del__ at 0x00000279CB52E940> Traceback (most recent call last): File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 322, in __del__ File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 317, in close File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 594, in _start_shutdown File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 599, in _write_appdata File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 707, in _process_write_backlog File "C:\Program Files\Python38\lib\asyncio\sslproto.py", line 721, in _fatal_error File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 151, in _force_close File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 715, in call_soon File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 508, in _check_closed RuntimeError: Event loop is closed

Error on Linux without uvloop:
Traceback (most recent call last): File "/usr/local/lib/python3.8/runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/lib/python3.8/runpy.py", line 86, in _run_code exec(code, run_globals) File "/mnt/app/__main__.py", line 49, in <module> asyncio.run(query()) File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete return future.result() File "/mnt/app/__main__.py", line 42, in query await con.copy_from_query("SELECT * FROM spot.csv_utc", format='csv', header=True, output="spot.csv") File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 591, in copy_from_query return await self._copy_out(copy_stmt, output, timeout) File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py", line 796, in _copy_out return await self._protocol.copy_out(copy_stmt, writer, timeout) File "asyncpg/protocol/protocol.pyx", line 341, in copy_out File "asyncpg/protocol/protocol.pyx", line 342, in asyncpg.protocol.protocol.BaseProtocol.copy_out File "asyncpg/protocol/coreproto.pyx", line 92, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages File "asyncpg/protocol/coreproto.pyx", line 359, in asyncpg.protocol.protocol.CoreProtocol._process__copy_out_data File "asyncpg/protocol/coreproto.pyx", line 428, in asyncpg.protocol.protocol.CoreProtocol._parse_copy_data_msgs File "asyncpg/protocol/protocol.pyx", line 847, in asyncpg.protocol.protocol.BaseProtocol._on_result File "asyncpg/protocol/protocol.pyx", line 769, in asyncpg.protocol.protocol.BaseProtocol._dispatch_result AttributeError: 'NoneType' object has no attribute 'cancelled'

Here is the code:
`import asyncio
import asyncpg

async def query():
con = await asyncpg.connect(auth here)
await con.copy_from_query("SELECT * FROM spot.csv_utc", format='csv', header=True, output="spot.csv")
await con.close()

if name == 'main':
asyncio.run(query())`

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 gọi copy_from_query với kết quả lớn được nêu trong issue bằng asyncio không có uvloop, sau đó kiểm tra asyncpg/connection.py, protocol.pyx và coreproto.pyx xung quanh traceback được báo cáo. Được xem là hoàn tất khi thao tác sao chép hoàn tất ổn định trên Windows và Linux mà không có uvloop, kèm theo kiểm thử hồi quy cho lỗi này.

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
Lĩnh vực
api, database
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
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.