Problem
Using python-hexagonal 0.3.0 scoped runtime with SQLAlchemy emits SAWarning: transaction already deassociated from connection on the integration-event publish path.
Reproduction context
Consumer repo: inteligencia-pdss-contactos
Path exercised through real app bootstrap and event publishing.
Focused pytest runs that reproduce it:
uv run pytest src/tests/use_cases/test_scoped_runtime.py -q -W always
uv run pytest src/tests/use_cases/contacto/test_marcar_contactado.py -q -W always
Observed stack direction
The warning appears during upstream outbox/message-bus handling:
BaseAPI.publish_and_wait()
MessageBus.publish_from_outbox()
SQLAlchemyOutboxRepository.mark_as_published()
SQLAlchemyConnectionContextManager.cursor() commit/transaction handling
Why this matters
The migration works functionally, but the warning suggests a transaction-boundary problem in nested or re-entrant outbox publishing. Even if it does not fail today, it is noisy and may hide a real edge case.
Request
Please review the SQLAlchemy outbox publish flow in scoped execution mode and ensure mark_as_published() / connection context handling does not commit against a transaction that has already been deassociated.
If useful, I can provide a minimized repro extracted from the consumer app path.
Problem
Using
python-hexagonal0.3.0 scoped runtime with SQLAlchemy emitsSAWarning: transaction already deassociated from connectionon the integration-event publish path.Reproduction context
Consumer repo:
inteligencia-pdss-contactosPath exercised through real app bootstrap and event publishing.
Focused pytest runs that reproduce it:
uv run pytest src/tests/use_cases/test_scoped_runtime.py -q -W alwaysuv run pytest src/tests/use_cases/contacto/test_marcar_contactado.py -q -W alwaysObserved stack direction
The warning appears during upstream outbox/message-bus handling:
BaseAPI.publish_and_wait()MessageBus.publish_from_outbox()SQLAlchemyOutboxRepository.mark_as_published()SQLAlchemyConnectionContextManager.cursor()commit/transaction handlingWhy this matters
The migration works functionally, but the warning suggests a transaction-boundary problem in nested or re-entrant outbox publishing. Even if it does not fail today, it is noisy and may hide a real edge case.
Request
Please review the SQLAlchemy outbox publish flow in scoped execution mode and ensure
mark_as_published()/ connection context handling does not commit against a transaction that has already been deassociated.If useful, I can provide a minimized repro extracted from the consumer app path.