Wrap fetch methods in asyncio.to_thread for aio pandas/arrow/polars cursors#674
Merged
laughingman7743 merged 4 commits intomasterfrom Feb 21, 2026
Merged
Conversation
…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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fetchone(),fetchmany(),fetchall(), and__anext__()inAioPandasCursor,AioArrowCursor, andAioPolarsCursorto wrap calls inasyncio.to_thread()chunksizetriggers lazy S3 reads (pandasTextFileReader/ polars batch generator)awaitfor fetch, consistent withAioCursorandAioS3FSCursorFixes #672
Test plan
make fmtpassesmake chkpasses (ruff lint + format + mypy)make testpassesAioPandasCursorwithchunksizeno longer blocks event loop during fetchAioPolarsCursorwithchunksizeno longer blocks event loop during fetchawait cursor.fetchone()works for all aio cursors🤖 Generated with Claude Code