From ce37751c44326fe9bb08be6bcf5f26ac64a2c7ed Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Wed, 23 May 2018 13:15:25 +0200 Subject: [PATCH] sqlalchemy: allow ping connection using dedicated flag for sqlachemy. - this is usefull flag but we don't need it to be connected to debug flag. --- rhodecode/lib/utils2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py index 8bbc85f6..65d52353 100644 --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -360,6 +360,10 @@ def engine_from_config(configuration, prefix='sqlalchemy.', **kwargs): normal = '\x1b[0m' return ''.join([color_seq, sql, normal]) + _ping_connection = configuration.get('sqlalchemy.db1.ping_connection') + if configuration['debug'] or _ping_connection: + sqlalchemy.event.listen(engine, "engine_connect", ping_connection) + if configuration['debug']: # attach events only for debug configuration @@ -381,8 +385,6 @@ def engine_from_config(configuration, prefix='sqlalchemy.', **kwargs): parameters, context, executemany): delattr(conn, 'query_start_time') - sqlalchemy.event.listen(engine, "engine_connect", - ping_connection) sqlalchemy.event.listen(engine, "before_cursor_execute", before_cursor_execute) sqlalchemy.event.listen(engine, "after_cursor_execute",