Fix async session handling by separating sync and async test execution#40
Closed
Copilot wants to merge 7 commits into
Closed
Fix async session handling by separating sync and async test execution#40Copilot wants to merge 7 commits into
Copilot wants to merge 7 commits into
Conversation
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Address test issues for async methods script
Fix async session handling in PGMQueue operations
Jan 6, 2026
jason810496
reviewed
Jan 6, 2026
Owner
jason810496
left a comment
There was a problem hiding this comment.
We should fix on the test side instead of _execute_operation, as we had already separate _execute_operation and _execute_async_operation.
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Contributor
Author
I've reverted the changes to Changes made:
All tests are now passing. Fixed in commit 889308c. |
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Copilot
AI
changed the title
Fix async session handling in PGMQueue operations
Fix async session handling by separating sync and async test execution
Jan 6, 2026
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.
Description
When PGMQueue is initialized with async DSN/engine/session_maker, the
_check_pgmq_ext()and_check_pg_partman_ext()methods were attempting to use sync context managers withAsyncSessionobjects, causingTypeError: 'AsyncSession' object does not support the context manager protocol.Changes
Following feedback to maintain strict separation between sync and async operations, the fix was implemented on the test side:
_check_pgmq_ext()and_check_pg_partman_ext(): Added async detection logic that routes to async versions (_check_pgmq_ext_async(),_check_pg_partman_ext_async()) whenis_asyncis Trueawaitin async contextscreate_partitioned_queue_async()anddrop_queue_async()now useawaitwhen calling async check methodscall_method()intests/_async_utils.pythat automatically routes to sync or async methods based on the PGMQueue instance typepgmq_setup_teardown,pgmq_partitioned_setup_teardown) and test methods now properly handle both sync and async PGMQueue instances using thecall_method()helperThis approach maintains the architectural separation between
_execute_operation(sync) and_execute_async_operation(async) while ensuring all tests work correctly with both sync and async PGMQueue instances.Example
Status
Checklist
pre-commitwithruff)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.