"Mike Bayer" <
mike_not_...@zzzcomputing.com> writes:
> can you add these assertions to env.py?
>
> with context.begin_transaction():
> assert not context.get_context()._in_external_transaction
> assert not connection.in_transaction()
> context.run_migrations()
>
> that's the condition necessary for begin_transaction() to call
> commit() at the end.
With those in place, the first one fails with this traceback:
16:56:36 [I] sqlalchemy.engine.Engine: BEGIN (implicit)
16:56:36 [I] sqlalchemy.engine.Engine: PRAGMA foreign_keys=OFF
16:56:36 [I] sqlalchemy.engine.Engine: [raw sql] ()
16:56:36 [I] sqlalchemy.engine.Engine: ROLLBACK
Traceback (most recent call last):
File "/home/lele/wip/sol5/env/bin/soladmin", line 33, in <module>
sys.exit(load_entry_point('SoL', 'console_scripts', 'soladmin')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lele/wip/sol5/src/sol/scripts/admin.py", line 640, in main
sys.exit((args.func(args) or 0) if hasattr(args, 'func') else 0)
^^^^^^^^^^^^^^^
File "/home/lele/wip/sol5/src/sol/scripts/admin.py", line 195, in upgrade_db
command.upgrade(cfg, "head")
File "/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/command.py", line 378, in upgrade
script.run_env()
File "/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/script/base.py", line 569, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
module = load_module_py(module_id, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lele/wip/sol5/env/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/lele/wip/sol5/alembic/env.py", line 88, in <module>
run_migrations_online()
File "/home/lele/wip/sol5/alembic/env.py", line 80, in run_migrations_online
assert not context.get_context()._in_external_transaction
AssertionError
That "soladmin" launcher is the CLI tool to manage the instance, that in
this case is just a thin wrapper around alembic.upgrade():
https://gitlab.com/metapensiero/SoL/-/blob/master/src/sol/scripts/admin.py#L173
And sorry for not having mentioned that another different cog I'm trying
out is running it with Python 3.11.
ciao, lele.