[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).
--- 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')