Skip to content

Comments

bump version to 0.7.1.post3 and enhance backward compatibility for as…#36

Merged
h0rn3t merged 3 commits intomainfrom
0.7.1.post3
Dec 23, 2025
Merged

bump version to 0.7.1.post3 and enhance backward compatibility for as…#36
h0rn3t merged 3 commits intomainfrom
0.7.1.post3

Conversation

@h0rn3t
Copy link
Owner

@h0rn3t h0rn3t commented Dec 23, 2025

This pull request restores and improves backward compatibility for asyncio.gather() usage with db.session.execute() in FastAPI applications using fastapi-async-sqlalchemy, and clarifies behavioral changes regarding session management in multi-session mode. It also adds comprehensive tests to cover both the backward compatibility fix and the new session caching behavior, including documentation for a breaking change introduced in a previous commit.

Backward Compatibility and Bug Fixes:

  • The session retrieval logic in middleware.py has been updated to gracefully handle cases where asyncio.current_task() raises a RuntimeError (e.g., in synchronous contexts), falling back to a single session mode instead of raising an error. This restores support for old usage patterns where asyncio.gather() is called without explicitly enabling multi_sessions. [1] [2]
  • The session cleanup logic in middleware.py is improved for robustness, ensuring cleanup tasks and session closing are handled correctly in both multi-session and single-session modes. [1] [2]

Testing and Documentation:

  • A new test file, test_backward_compat_gather.py, is added to verify that common patterns using asyncio.gather() with db.session.execute() work as expected without requiring multi_sessions=True, ensuring backward compatibility for existing production code.
  • The test coverage for edge cases is improved in test_coverage_improvements.py, verifying that the fallback to sync context works when current_task() returns None. [1] [2]
  • A new regression test file, test_regression_concurrent.py, is added to document and demonstrate the breaking change in session management introduced in commit 4e99374. This includes migration guidance and tests that illustrate the new requirement for wrapping parallel queries in separate async functions when using multi_sessions=True.

Versioning:

  • The package version is bumped to 0.7.1.post3 to reflect these changes and fixes.

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9]…yncio.gather() without multi_sessions flag

…yncio.gather() without multi_sessions flag
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.13%. Comparing base (374edba) to head (3c6989f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
+ Coverage   96.71%   98.13%   +1.42%     
==========================================
  Files           3        3              
  Lines         152      107      -45     
==========================================
- Hits          147      105      -42     
+ Misses          5        2       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openhands-ai
Copy link

openhands-ai bot commented Dec 23, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • ci

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #36 at branch `0.7.1.post3`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@h0rn3t h0rn3t merged commit b1dcf4b into main Dec 23, 2025
9 checks passed
@h0rn3t h0rn3t deleted the 0.7.1.post3 branch December 23, 2025 14:46
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.

1 participant