# HG changeset patch # User Denis Laxalde # Date 1491571418 -7200 # Node ID 4db0f22519600071d5f54e3e9f61c977f2a26ba1 # Parent 6069ee7d482445c364019dcd63bb686724bfe85d [pyramid] Avoid shutting down the repository at exit if it's already shutting down For install `cubicweb-ctl pyramid` command will explicitly call `repo.shutdown()` so the atexit hook is redundant. Prevent the latter to be executed when the repository is already shutting down (otherwise one gets an assertion error). diff -r 6069ee7d4824 -r 4db0f2251960 cubicweb/pyramid/__init__.py --- a/cubicweb/pyramid/__init__.py Wed Apr 05 14:42:30 2017 +0200 +++ b/cubicweb/pyramid/__init__.py Fri Apr 07 15:23:38 2017 +0200 @@ -226,7 +226,11 @@ config.registry['cubicweb.registry'] = repo.vreg if cwconfig.mode != 'test': - atexit.register(repo.shutdown) + @atexit.register + def shutdown_repo(): + if repo.shutting_down: + return + repo.shutdown if asbool(config.registry.settings.get('cubicweb.defaults', True)): config.include('cubicweb.pyramid.defaults')