Skip to content

Comments

Wrap fetch methods in asyncio.to_thread for aio pandas/arrow/polars cursors#674

Merged
laughingman7743 merged 4 commits intomasterfrom
fix/aio-cursor-fetch-event-loop-blocking
Feb 21, 2026
Merged

Wrap fetch methods in asyncio.to_thread for aio pandas/arrow/polars cursors#674
laughingman7743 merged 4 commits intomasterfrom
fix/aio-cursor-fetch-event-loop-blocking

Conversation

@laughingman7743
Copy link
Member

Summary

  • Override fetchone(), fetchmany(), fetchall(), and __anext__() in AioPandasCursor, AioArrowCursor, and AioPolarsCursor to wrap calls in asyncio.to_thread()
  • Prevents event loop blocking when chunksize triggers lazy S3 reads (pandas TextFileReader / polars batch generator)
  • Unifies the API so all aio cursors require await for fetch, consistent with AioCursor and AioS3FSCursor
  • Updates documentation to reflect the new async fetch behavior and removes chunksize blocking warnings

Fixes #672

Test plan

  • Verify make fmt passes
  • Verify make chk passes (ruff lint + format + mypy)
  • Verify make test passes
  • Manual test: AioPandasCursor with chunksize no longer blocks event loop during fetch
  • Manual test: AioPolarsCursor with chunksize no longer blocks event loop during fetch
  • Verify await cursor.fetchone() works for all aio cursors

🤖 Generated with Claude Code

…ursors

Override fetchone(), fetchmany(), fetchall(), and __anext__() in
AioPandasCursor, AioArrowCursor, and AioPolarsCursor to use
asyncio.to_thread(), preventing event loop blocking when chunksize
triggers lazy S3 reads. This unifies the API so all aio cursors
require await for fetch operations, consistent with AioCursor and
AioS3FSCursor.

Fixes #672

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
laughingman7743 and others added 2 commits February 21, 2026 14:34
Tests were calling fetchone(), fetchmany(), fetchall() without await,
producing "coroutine was never awaited" warnings and incorrect
assertions (comparing coroutine objects instead of results).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ning

pytest-asyncio warns that future versions will default the loop scope
for async fixtures to function scope. Set it explicitly to "function"
to suppress the deprecation warning and ensure consistent behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Base automatically changed from docs/native-asyncio-cursors to master February 21, 2026 05:35
@laughingman7743 laughingman7743 marked this pull request as ready for review February 21, 2026 05:35
@laughingman7743 laughingman7743 merged commit cd56348 into master Feb 21, 2026
13 of 15 checks passed
@laughingman7743 laughingman7743 deleted the fix/aio-cursor-fetch-event-loop-blocking branch February 21, 2026 06:36
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

Successfully merging this pull request may close these issues.

AioPandasCursor/AioPolarsCursor: chunksize fetch blocks the event loop

1 participant