[pyramid] Call repository's shutdown method atexit
This way when run through a WSGI server (pserve, gunicorn, etc.) we make sure
that the repository is properly shut down. In particular, this would wait for
threads to terminate (otherwise, they'll be killed).
--- a/cubicweb/pyramid/__init__.py Fri Mar 03 11:13:03 2017 +0100
+++ b/cubicweb/pyramid/__init__.py Fri Mar 10 12:02:41 2017 +0100
@@ -20,8 +20,10 @@
"""Pyramid interface to CubicWeb"""
+import atexit
import os
from warnings import warn
+
import wsgicors
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
@@ -224,6 +226,8 @@
repo = config.registry['cubicweb.repository'] = cwconfig.repository()
config.registry['cubicweb.registry'] = repo.vreg
+ atexit.register(repo.shutdown)
+
if asbool(config.registry.settings.get('cubicweb.defaults', True)):
config.include('cubicweb.pyramid.defaults')