cubicweb #2345728 no db connexion available on shutdown [validation pending]

Traceback (most recent call last):
 File "/home/auc/bin/cubicweb-ctl", line 4, in <module>
   run(sys.argv[1:])
 File "/home/auc/src/fcw/cubicweb/cwctl.py", line 1017, in run
   CWCTL.run(args)
 File "/home/auc/src/fcw/logilab/common/clcommands.py", line 134, in run
   sys.exit(command.main_run(args, rcfile))
 File "/home/auc/src/fcw/logilab/common/clcommands.py", line 263, in main_run
   self.run(args)
 File "/home/auc/src/fcw/cubicweb/server/serverctl.py", line 702, in run
   server.run()
 File "/home/auc/src/fcw/cubicweb/server/server.py", line 112, in run
   self.trigger_events()
 File "/home/auc/src/fcw/cubicweb/server/server.py", line 97, in trigger_events
   event.fire(self)
 File "/home/auc/src/fcw/cubicweb/server/server.py", line 72, in fire
   server.repo.shutdown()
 File "/home/auc/src/fcw/cubicweb/server/repository.py", line 434, in shutdown
   self.hm.call_hooks('server_shutdown', repo=self)
 File "/home/auc/src/fcw/cubicweb/server/hook.py", line 410, in call_hooks
   registry.call_hooks(event, session, **kwargs)
 File "/home/auc/src/fcw/cubicweb/server/hook.py", line 307, in call_hooks
   hook()
 File "/home/auc/src/fcw/cubes/worker/hooks.py", line 65, in __call__
   with temp_session(repo) as session:
 File "/usr/lib/python2.6/contextlib.py", line 16, in __enter__
   return self.gen.next()
 File "/home/auc/src/fcw/cubes/worker/utils.py", line 16, in temp_session
   session = repo.internal_session()
 File "/home/auc/src/fcw/cubicweb/server/repository.py", line 1027, in internal_session
   session.set_cnxset()
 File "/home/auc/src/fcw/cubicweb/server/session.py", line 783, in set_cnxset
   if self.cnxset is None:
 File "/home/auc/src/fcw/cubicweb/server/session.py", line 1283, in cnxset
   raise ShuttingDown('repository is shutting down')
cubicweb.server.ShuttingDown: repository is shutting down

My guess: we actually want a before_shutdown event where cnxsets are available.

priorityimportant
typebug
done in3.15.1
load0.300
load left0.000
closed by#77c7158916c1 [events] add a new before_shutdown event (closes #2345728)