[pull] main from apache:main - #156
Merged
Merged
Conversation
* fix: support `async with` on async persister factory methods `AsyncSQLitePersister.from_values()` and `AsyncPostgreSQLPersister.from_values()` were async classmethods returning coroutines, which cannot be used directly with `async with`. This wraps them in `_AsyncPersisterContextManager` that supports both `await` (backwards compatible) and `async with` protocols. Closes #546 * refactor: move _AsyncPersisterContextManager to burr/common/async_utils.py and add tests Address review feedback: - Move _AsyncPersisterContextManager from b_aiosqlite.py to burr/common/async_utils.py to avoid cross-dependency between unrelated integrations - Add type annotation to coro parameter - Add tests for async with pattern on from_values and from_config * fix: guard against __aexit__ crash and double consumption in context manager wrapper - __aexit__ now returns False when __aenter__ failed (persister is None), preventing AttributeError that would mask the original exception - Add _consumed flag to prevent silent coroutine reuse, raising RuntimeError with clear message on second await/async with - Add tests for both edge cases * docs: fix async persister examples and remove redundant test helpers - Add missing `await` to from_values() calls in parallelism.rst docs - Remove AsyncSQLiteContextManager helper class from both test files, now that from_values() natively supports async with - Replace deprecated .close() calls with .cleanup() in test fixtures * style: fix black formatting and isort import order * style: reformat with black 23.11.0 (project version) * ci: trigger workflow rerun
* core: add flexible_api decorator to fix mypy override errors on class-based actions Adds a `flexible_api` decorator that users can apply to `run`, `stream_run`, or `run_and_update` overrides that use explicit parameters instead of `**run_kwargs`. This prevents mypy [override] errors caused by narrowing the base-class signature. Closes #457 * style: apply black formatting * Rename flexible_api to type_eraser and fix async support Address review feedback: rename decorator per maintainer suggestion. Fix critical bug where @wraps on async/generator functions broke is_async() detection. Add tests for all function types.
* fix: allow streaming actions to gracefully handle raised exceptions When a streaming action catches an exception and yields a final state in a try/except/finally block, the stream now completes gracefully instead of propagating the exception and killing the connection. If the generator yields a valid state_update before the exception propagates, the exception is suppressed and the stream terminates normally. If no state was yielded, the exception propagates as before. Closes #581 * fix: add logging for suppressed exceptions and tests for streaming graceful shutdown - Add logger.warning with exc_info in all 4 streaming except blocks - Remove dead caught_exc variable in multi-step functions - Fix count increment asymmetry between sync and async single-step - Add 8 tests covering graceful exception handling and propagation * style: apply black formatting * style: apply pre-commit formatting (black 23.11.0, isort 5.12.0)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )