Try to configure the 'pyramid_retry' package, if available

this is used (as of pyramid 1.9) for gracefully handling postgres restarts
This commit is contained in:
Lance Edgar 2018-10-25 14:33:28 -05:00
parent 3df1407073
commit 92c1b165fb

View file

@ -96,7 +96,12 @@ def provide_postgresql_settings(settings):
this enables retrying transactions a second time, in an attempt to this enables retrying transactions a second time, in an attempt to
gracefully handle database restarts. gracefully handle database restarts.
""" """
try:
import pyramid_retry
except ImportError:
settings.setdefault('tm.attempts', 2) settings.setdefault('tm.attempts', 2)
else:
settings.setdefault('retry.attempts', 2)
class Root(dict): class Root(dict):
@ -135,6 +140,15 @@ def make_pyramid_config(settings, configure_csrf=True):
config.include('pyramid_mako') config.include('pyramid_mako')
config.include('pyramid_tm') config.include('pyramid_tm')
# bring in the pyramid_retry logic, if available
# TODO: pretty soon we can require this package, hopefully..
try:
import pyramid_retry
except ImportError:
pass
else:
config.include('pyramid_retry')
# Add some permissions magic. # Add some permissions magic.
config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group') config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group')
config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission') config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission')